LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Keyboard hook (https://www.linuxquestions.org/questions/programming-9/keyboard-hook-3768/)

sudheerd 06-27-2001 11:59 PM

Keyboard hook
 
Hello,
Is it possible implement a systemwide keyboard hook under Linux? (Suppose I want to invoke a function in my application upon pressing the key F1 (EVEN IF MY APPLICATION HAS LOST FOCUS)). Is this possible under Linux?. Please help

Thanks
Sudheer.

commandob 07-07-2001 09:31 PM

I'll assume that you're referring to programs running in XWindows.

Here's a possible solution using WindowMaker:

Edit the WindowMaker file (either by hand, or with wmakerconf or WPrefs) to add a new command to the root menu (that appears when you right click on the background). Here you can associate a file to execute (or do whatever with) with a keyboard shortcut. I just wrote a script that toggles my keyboard from the german layout to the US and vice versa and associated it with a key combination using this method. it works well, is executed in the background, and is independently of the focus.



I know that Sawmill also allows one to bind shortcuts if you're running gnome; however, I'm not sure if you can change more than just the window commands.



I hope this helps some. I suspect some of the other window managers may support something similar, although I haven't played around with them as much. Good luck!

Cheers!


All times are GMT -5. The time now is 09:23 PM.