Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to create myself very tiny app, which will play a sound every time I press a key on my keyboard. I don't need to know which key on the keyboard was pressed, I just need to somehow know that it happened.

Are there any global system hooks for pressed key on the keyboard?

share|improve this question
You could grab the keyboard with an X api call – karthick87 Dec 11 '10 at 19:40

Here's a method that in theory should work.

If you visit the "Accessibility" tab in System>Preferences>Keyboard then you can enable the "Slow Keys" "Only accept long keypresses" option. Turn the delay all the way down and you basically null the effects of this option. Then go to "Audio Feedback..." and enable "Beep when a key is pressed" under the "Slow Keys" section.

Configuration Dialogs

This method SHOULD work. I couldn't get it to work, honestly. I do have the sound-theme-freedesktop sound theme installed and enabled. Perhaps it's a bug with gnome 2.32.0.

These configuration options simply play the system bell. On Ubuntu the system bell does not work when desktop effects are enabled. Turn off desktop effects, or on Ubuntu 11.04 login as "Ubuntu Classic (No effects)", and your system bell should work again.

share|improve this answer
Here you go. Added. – user6658 Jan 23 '11 at 1:42

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.