Re: [code] [textadept] Hotkeys in other locale

From: Robert Gieseke <>
Date: Wed, 04 Sep 2013 16:10:08 +0200


Am 9/4/13 12:49 PM, schrieb A.M. Genaev:
> Hi,
> The most of key bindings doesn't work when i switch to Russian.
> Is there a way to do hotkeys to be locale-independent?

As Mitchell wrote Textadept doesn't use key codes but chars.
You could try the following hack to use the same keybindings.

Textadept has the keys.KEYSYMS table to look up key codes greater than
255 (it's in core/keys.lua). You could add mappings from the Cyrillic
letters to the Latin ones used in short cuts.

An example:
When I switch to a Russian layout and press 's' I get 'ы'.

In my 'init.lua' I put
_G.keys.KEYSYMS[1753] = 's'

Now I can press the 'Ctrl s' or 'Cmd s' shortcuts and get the expected
behaviour, without the modifier it's still yery, 'ы'.

To get the key code you can comment out the first print statement in the
keypress function in core/keys.lua. I think these numbers are GTK
specific so you could look them up, I've found this table for PyGTK with
Hex representations:

So if you can figure out a mapping from Cyrillic to Latin letters you
could probably write a for loop otherwise you would have to add them one
by one.
Unfortunately this approach doesn't work for short cuts with shift due
to the way Textadept core/keys module handles shift keys. (This might be
worth investigating…)

Here is an example for directly assigning cyrillic short cuts:
keys.KEYSYMS[1753] = 'ы'
keys.KEYSYMS[0x6f9] = 'Ы'
keys['cы'] =
keys['csЫ'] = buffer.save_as

Note that you have to define the KEYSYMS mappings and that for short
cuts with shift you need to explicitly use 's' for cyrillic letter, for
keys['csЫ'] = buffer.save_as
keys['cS'] = buffer.save_as

I hope this wasn't a too confusing explanation :-)

You are subscribed to
To change subscription settings, send an e-mail to
To unsubscribe, send an e-mail to
Received on Wed 04 Sep 2013 - 10:10:08 EDT

This archive was generated by hypermail 2.2.0 : Thu 05 Sep 2013 - 06:25:58 EDT