PDA

View Full Version : how to write code for creating keyboard shortcut



kemparaju
September 29th, 2011, 12:34 PM
Hi,

I am trying to write the code for getting combination of key press as input and executes the corresponding commands.
but my requirement is that, my application should be running in backround, where ever if we press the key, my application should get the input of which key has been pressed. please help me out from this problem.

thanks in advance
Kemparaju

narasi
September 29th, 2011, 12:50 PM
This application is being developed for which system?

WasMeHere
September 29th, 2011, 01:56 PM
Do you want to integrate it into an application program, that you develop? In that case you must use the facilities that are available in your programming language.

Or do you want Ubuntu to perform a task, when you enter a key combination? In that case it is quite easy:

Select the menu System -- Settings -- Keyboard Shortcuts

and in the 'Keyboard Shortcuts' window press the 'Add' button for a new action and/or select the (now listed) action and enter or change its shortcut.

kemparaju
September 30th, 2011, 02:22 PM
I am trying to write a program, which will be running at backround and if we press any key, then it will write that key into a file.
for example if we press Alt+k then it will write Alt+k into a file.

WasMeHere
September 30th, 2011, 07:17 PM
I am trying to write a program, which will be running at backround and if we press any key, then it will write that key into a file.
for example if we press Alt+k then it will write Alt+k into a file.
This is actually done by the keyboard shortcut program of my previous post. Its command name in terminal is
gnome-keybinding-propertiesIt is a viewer and editor of a file. Do you want to know the path to that file? Do you want your program to listen all the time, or only when you configure a shortcut?

Remember that linux is open source, so you can get the source code of it and modify it to fit your needs!

Have fun
Olle

karlson
September 30th, 2011, 07:56 PM
I am trying to write a program, which will be running at backround and if we press any key, then it will write that key into a file.
for example if we press Alt+k then it will write Alt+k into a file.

Any reason to write your own keystroke logger?
You can actually start with this:

http://sourceforge.net/projects/lkl/

kemparaju
October 3rd, 2011, 07:47 AM
Thanks for your valuable reply,

I am using "logKeys", for this we have to mention keymap, so how to know which keymap we are using.


Thanks
Kemparaju