jigish / slate

A window management application (replacement for Divvy/SizeUp/ShiftIt)
GNU General Public License v3.0
7.85k stars 510 forks source link

Extend set of allowed keys #133

Open purcell opened 11 years ago

purcell commented 11 years ago

On non-US keyboards there are a variety of non-ASCII characters which can be typed with a single keypress; for example, Apple's British keyboards have a "§" just below the escape key (where the backtick would be on a US keyboard). Various European layouts have certain accented characters on their own keys.

It'd be great to be able to use those keys for bindings too, particularly because they are extremely unlikely to be used by other keychord-intensive apps.

jigish commented 11 years ago

I can definitely do this but unfortunately I would need the mapping between the key itself and the OS X key code. I'll see if i can dig it up myself and update here if i can.

jbleuzen commented 11 years ago

Hi, I'm french and I also would love to see more non-ASCII characters mapped in Slate... There is an app called KeyCodes (I'm not related with the author) that will tell you all infos about the key you press...

http://manytricks.com/keycodes/

After, maybe the best thing would be to have a list of characters that people would like to see implemented. They can provide the character and the Keycode value...

It was my two cents

purcell commented 11 years ago

Hey, so if you switch keyboard layouts to Dvorak, do the keycodes for the alphabet characters change? ie. do the keycodes identify physical keys?

jigish commented 11 years ago

@purcell key codes identify physical keys which is why you need the config for dvorak if you use it. I maintain a hash from key character -> key code (there is no reverse lookup built in to Objective-C unfortunately) for both dvorak and qwerty.

@jbleuzen I think you have the right idea. Thats the app I used to get my initial values. Unfortunately I don't have any non-US keyboards laying around so I can't really test it all out. It would be great if we could compile a list of keys everyone would like to see and I can add them in. For this I would need:

  1. The character representation of the key. For example '3'. Note that the key should not be created using modifiers. This means '3' is good, '#' is not.
  2. The key code that the character represents on qwerty
  3. The key code that the character represents on dvorak

If I can get this information I can start adding keys that people want one by one.

jigish commented 11 years ago

Another option would be for me to add a config directive that you can use to specify additional keys and their corresponding key code. This may work well as a temporary solution.

purcell commented 11 years ago

Perhaps you could support a syntax in the config file for specifying the key code directly, e.g. [1243].

jigish commented 11 years ago

True. That would remove the need for yet another config and you can always use aliases to make it prettier. I like it.

purcell commented 11 years ago

I can also imagine a perverse scheme where you'd fire all possible key codes into a hidden text field, and see what characters come out -- you could then create a look-up table mapping characters back to key codes... bleurgh!

tadhg-ohiggins commented 11 years ago

While this isn't an ideal solution, you can write to /Applications/Slate.app/Contents/Resources/ASCIIToCode.plist (or one of the others if you're using a different keyboard variant) and enter key/integer pairs for any keystroke; you can then refer to that key in Slate config files. I've only tried this with Slate JavaScript configs.

If you're looking for a list of key codes, this isn't the worst place to start: https://github.com/tekezo/KeyRemap4MacBook/blob/version_8.3.0/src/bridge/generator/keycode/data/KeyCode.data (note that KR4MB uses hex and Slate decimal).

Incidentally, you aren't confined to real keys: you can tell Slate to listen for an arbitrary key code and generate that with e.g. KR4MB. That's the method I'm using to avoid chord conflicts between Slate and other applications.

qguv commented 8 years ago

I use Colemak, so this affects me too. I'm working on a patch.

Edit: I just found the config option to change keyboard layout, so I'm dropping my patch.