Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

First of all, I don't expect that something like this already exists, but I am interested in knowing how something like this would be accomplished.

I want a program that I can have running in the background that will intercept ALL keystrokes entered (I'm assuming X is running and perhaps even that Unity is also running), process those keystrokes and then send the original or modified keystrokes on to be handled as normal.

My ultimate goal is creating a sort of keymapping that more closely mimics OS X shortcut behavior. This is very difficult with a standard Ubuntu install since things like ctrl+c seem to be set in stone whereas to mimic OS X behavior, it would need to be cmd+c. Anyway, I'm less interested in discussing the why and more interested in discussing the how. I'm not adverse to writing a daemon in Python, C or whatever else might be needed (I'm also somewhat comfortable with standard UNIX apis). I am, however, completely ignorant about where to begin with something like this.

When the keystrokes are intercepted and processed, it should be able to send them back to the OS following the same interface that the strokes were originally sent with. Maybe this would have to be a patch to X itself? Or would something be able to be in place between the keyboard and X?

share|improve this question
Good place to start.. you're basically looking for a keylogger, but with slightly modified behaviour? askubuntu.com/questions/14180/how-can-i-install-a-keylogger –  Caesium Dec 13 '11 at 2:30
sort of, I definitely need to be able grab all keys entered. But I'm more interested in how to intercept and process the input before X or whatever else might handle it rather than just recording it. –  greggory.hz Dec 13 '11 at 2:50
perhaps a compiz plugin is the way to go? –  greggory.hz Dec 13 '11 at 9:58

1 Answer 1

Yes there is a keylogger for ubuntu..

You can download it from here

Or you install it via apt-get

Enable universe repositories,and then run the following in terminal

sudo aptitude update
sudo aptitude install lkl

To run,type the following in terminal

lkl -l -k us_km -o log.file

for seeing results

tail log.file

share|improve this answer
I'm not looking for a keylogger. I'm more looking for a way to create a keylogger. I want to effectively modify the keyboard layout and cause certain keys to be sent on to X as something different than what was actually pressed. I don't need to a log keys hit from a user's session. –  greggory.hz Mar 1 '12 at 21:04
This is what you're looking for, you just don't want to read source –  hbdgaf Mar 31 '12 at 4:53

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.