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?

  • 1
    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.

  • Here you go. Added. – user6658 Jan 23 '11 at 1:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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