Home Download Buy Blog Forum Support

Key Binding problems with non-US keyboard

Key Binding problems with non-US keyboard

Postby rasp on Sat Mar 31, 2012 11:17 am

Hi,

Some of the default Key bindings are not usable on my (Scandinavian) keyboard. E.g. ctrl+[ or ctrl+] are not possible, as the []-characters always require Alt to be pressed as well.

I tried making my own key bindings by comparing my keyboard layout to a US layout and changing the default bindings accordingly (the idea was to map the commands to the same physical locations as on the US layout). The resulting user-binding file:

Code: Select all
[
    { "keys": ["ctrl+¨"], "command": "indent" },
    { "keys": ["ctrl+å"], "command": "unindent" },

    { "keys": ["ctrl+¨"], "command": "show_overlay", "args": {"overlay": "goto", "text": "#"} },

    { "keys": ["ctrl+-"], "command": "toggle_comment", "args": { "block": false } },
    { "keys": ["ctrl+shift+-"], "command": "toggle_comment", "args": { "block": true } }

    { "keys": ["ctrl+§"], "command": "show_panel", "args": {"panel": "console", "toggle": true} },

    { "keys": ["ctrl+shift+å"], "command": "fold" },
    { "keys": ["ctrl+shift+¨"], "command": "unfold" }
]


However, the only bindings that seem to come through are the ctrl+- and ctrl+shift+- which do get mapped to toggle_comment. All other mappings do not work.

I troubleshooting by enabling command logging (by writing sublime.log_commands(1) in the console window), but it only shows which commands are getting activated, not how Sublime Text interpreted the keyboard combo that triggered it, so I don't see a way to find out what I should actually write into the Key bindings file to get things working with the keys I would like.

Any ideas? Is this by any chance related to the reportedly lacking Unicode support in Python 2 (http://wiki.python.org/moin/Python2orPython3)?
rasp
 
Posts: 4
Joined: Sat Mar 31, 2012 11:02 am

Re: Key Binding problems with non-US keyboard

Postby jps on Sat Mar 31, 2012 11:19 am

Your best bet is to use sublime.log_input(True) in the console, to see the key names that are getting sent to Sublime Text
jps
Site Admin
 
Posts: 3077
Joined: Wed Mar 19, 2008 12:33 pm

Re: Key Binding problems with non-US keyboard

Postby rasp on Sat Apr 07, 2012 6:51 pm

Thanks for the tip! That allowed me to see what Sublime thought was being pressed. It seems that when I use only single keys at a time, they are correctly interpreted; but when certain keys (that differ between the US/UK and Scandinavian layouts) are used in combinations with Alt or Ctrl, they are often read incorrectly:

Code: Select all
Table: Sublime's interpretation of keys in alt/ctrl combos on Swedish/Finnish keyboards
  Actual key  |
  used in the | Sublime reads
  combination | key as
  ------------+--------------
       ¨      |      ;
       å      |      ]
       §      |      \
       ´      |      [
       '      |      /
       +      |      =

Swedish/Finnish keyboard:
Image
UK Keyboard:
Image
As a result, I was able to get commands mapped to the same physical keys as on the UK keyboard layout. Its not a very satisfactory solution though, because the menu labels for the keyboard shortcuts now are just plain wrong and give no memory aid for remembering the shortcuts.

If anyone knows the answer, I'm still interested to know what the underlying problem is - Python's Unicode support or somehting else? Any hope of Sublime switching to Python 3 (if that would help) or correcting this in some other way?
rasp
 
Posts: 4
Joined: Sat Mar 31, 2012 11:02 am

Re: Key Binding problems with non-US keyboard

Postby jps on Sun Apr 08, 2012 2:14 am

This is a natural result of the virtual key code system in Windows, and isn't related to Python.
jps
Site Admin
 
Posts: 3077
Joined: Wed Mar 19, 2008 12:33 pm


Return to Technical Support

Who is online

Users browsing this forum: Alexa [Bot], Clams and 9 guests