25

Is there a way to define an association of a particular physical key of the keyboard to some action, independently of the letter that this key is associated to in any layout?

Example: In most default Gnome shortcut key associations, pressing Alt + Ctrl + T opens a terminal. But only in the Latin keyboard layout. Doing the same physical action while in Greek layout does not work, since the associated letter is then the "Greek T", not the "Latin T".

Therefore, one has first to switch to the Latin layout and then press the shortcut key, which may be frustrating since one is never sure if the key has not been pressed correctly at the first place, so probably tries several times until realizing that the problem was in the layout.

A solution could be defining the same association for the same key in all layouts one uses - but then one would have to do this for all shortcuts, so this solution does not scale well.

20

I often switch between English and Greek layouts and this has been a minor annoyance for a while. Your question pushed me to solve it, so thanks!

I found a program that can do this: xbindkeys. The proceedure I followed (adapted from here) was:

  1. Install xbindkeys. On my Debian this is done with

    sudo apt-get install xbindkeys
    

    You should also be able to install easily enough with the equivalent yum install or pacman -S or whatever commands.

  2. Create the default settings file:

    xbindkeys --defaults > `~/.xbindkeysrc`
    
  3. Get the right keycodes for your keys. Run xbindkeys -k and press your desired shortcut. With my keyboard at least (though this should be standard), xbindkeys -k reports that CtrlT is

    m:0x14 + c:28
    Control+Mod2 + t
    
  4. Create the relevant shortcut, add these lines to ~/.xbindkeysrc:

    "xterm"
     m:0x14 + c:28
    
  5. Run xbindkeys. The shortcut now works even in the Greek layout. To make this permanent, add this to your ~/.Xsession:

    xbindkeys
    
  • 1
    xbindkeys does what I need. And, yes, Alt + Ctr + T is the default, not Ctrl + T. I corrected the question. I am wondering though why Gnome has chosen correspondence with letters rather than with key codes – serxio Sep 24 '13 at 10:11
  • 1
    @serxio perhaps keycodes change on different keyboards? Or you can remap things so Gnome calls the key by name so it won't be confused if you've mapped Ctrl to Alt or something? Trexa gyreye. – terdon Sep 24 '13 at 15:50

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.