When you first look at this question and its title you are going to assume that I want this for malicious purposes, however that is not the case, it is because I type a lot of things, and sometimes (rather often actually) I just want to check what I did, say, half an hour ago, or make sure that I didn't just make a big mistake, however there is no real history of what I type so this becomes rather difficult.
Another reason for this might be that my computer is running certain tasks which should not be interrupted until complete, so I can't suspend my machine, but I would like to be able to come back and tell if anybody typed anything (because most often this is a CLI only session so I don't need to worry about the mouse and I can use other software such as screen recording for that), or executed any keyboard shortcuts.
So, long story short, I would like a "keylogger" however I do not want to install one from anywhere as I don't trust that there aren't any backdoors or anything, so what I would like is a script (and I know that this sort of thing is possible) which:
Is able to record (probably in a text file) keystrokes and also when the pressing of a key once results in the character coming out more than once
Is able to tell apart keyboard shortcuts from normal typing and also show what the result of the keyboard shortcut was
Works in the GUI and CLI
Works on Ubuntu GNOME 15.10 with GNOME 3.18 (my system)
Preferably written in a language such as bash
Only keeps a log of the last 5 minutes (though this should be a variable time which can be easily changed in the code)