I have an Asus laptop that has a special key that can be configured to launch any software (at least on Windows).
The general question is: how can I detect any key press (globally)?
Then, how can I detect when the user press this key?
keyboardkeyboard shortcutsx-server
I have an Asus laptop that has a special key that can be configured to launch any software (at least on Windows).
The general question is: how can I detect any key press (globally)?
Then, how can I detect when the user press this key?
Best Answer
I typically will use
xev
to determine the key's scancode and then map it to whatever action I want using either xdotool or XBindKeys.xev
After running the above
xev
command you'll get a little white window that'll pop up. You'll want to put the mouse over this window and then press the problem key. The name of the key should be showing up in the terminal as you press the various keys.Screenshot
mapping the key to something useful
You can create shortcut key combinations that will launch commands using
xbindkeys
, for example. I've successfully been using XBindKeys on GNOME 3.8.4 for this very purpose.My use has been modest but I like to create keyboard shortcuts for Nautilus to launch with certain directories opened.
Example
You'll need to first make sure the packages
xbindkeys
is installed.Then you'll need to run the following command, one time only, to create a template
xbindkeys
configuration file.With the file created you can open it in a text editor and add a rule like this:
With the above change made we need to kill
xbindkeys
if it's already running and then restart it.Now with this running any time I type Mod+Shift+Q Nautilus will open with the corresponding folder opened.
Using GNOME's Keyboard Applet
If you go through the settings (System Settings → Keyboard, select Shortcuts tab and add a new custom shortcut for your browser.
Using the steps 1-5 as in the diagram you could map a command to your special key as well.