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.

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
1  
You could grab the keyboard with an X api call –  karthick87 Dec 11 '10 at 19:40

1 Answer 1

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

 
discard

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.