Thursday, September 11, 2014

Metakey Kludge

I'll let Ted from the Google Group describe his ingenious new solution for Plover's lack of arbitrarily stackable metakeys. (You can explicitly define a metakey+key combination in the dictionary, but you can't map a stroke to, say, Control and then be able to simulate holding it down while choosing another key in realtime to be activated along with it.)

Hello PloverSteno!

Intro:

I've seen complaints in the past about the lack of a "sticky modifier" function in Plover. The idea being that you could define a stroke for Shift, one for Control, then using these strokes write something like "Control/Shift/p" or any other stroke.

Well, today I'd like to announce my workaround!

It's a Python script that takes a list of modifiers (Control, Super, Alt, Shift, by default) and a list of hotkeys (alphanumeric, enter, backspace, delete, and arrow keys, by default) and then generates every *possible* combination in order to give you one-off hotkeys. The output is a dictionary that you load into Plover and you're ready to go.

Of course, I recommend a single stroke for something common like "Ctrl-v" for paste, but sometimes you just need a one-off "Control-alt-shift-Left arrow" and that's what this script aims to let you do.

As a little bonus, there's a definition in there that has 100 strokes in order to increase Plover's buffer length.

Usage:

If you don't like my default strokes, you can go into the script and change the "modifiers" or "hotkeys" lists in the main method. But these are the defaults, as per the script:

- Alt/Option: TLA* (THRA*)
- Command: KM* (KPL*)
- Control: KL* (KHR*)
- Shift: SF* (STP*)

Otherwise all the letters, numbers, return, and backspace are all Plover default.

Of note, if you want to just "press" the combination without a key, for example in Windows you can use "Ctrl+Shift" to change keyboard layouts, use the blank stroke:

- "SP*S"

I also had to add an entry for the delete key, which is just:

- DLAO*ET (TKHRAO*ET)

Download:

Download it from the GitHub repo. "modifiers.json" is the dictionary with all my defaults, "makeShortcuts.py" is the Python script to run to make the dictionary.

Please, feedback is welcome. Also think of this as a workaround, not a permanent solution to the problem.


Many thanks to Ted for this! I have a feeling it'll come in extremely handy.

3 comments:

robpaulsen said...

I really don't understand why people complain about not having stackable metakeys in plover. You can just enable sticky keys in your operating system and the problem is solved. Type "ctrl", then "alt", then "del" and the operating system automatically interprets it as "ctrl+alt+del". There should be no need to fill the dictionary with stupid all-possible-combinations definitions.

robpaulson said...

On the other hand, I was thinking, that having such a feature directly integrated in plover would be good. For example, if you have a stenosaurus or something like that and you want to use it with someone else's computer, you don't want to mess with OS's settings. Maybe it would be best if some strokes like "ctrl", "alt" and "shift" had a sticky key behavior by default. You never want to press "shift" or "ctrl" alone, you would like plover to wait for the next stroke to complete the command.

Ted Morin said...

Hi Rob,

I don't know about you, but I'm always changing between Plover and a normal keyboard. Having sticky keys on would be annoying.

The other thing is, sometimes you do want to just press a modifier alone. Often "Alt" is used to discover hidden functions of a program.

In any case, I was really just looking to fill a gap where a bunch of people were asking for a feature. And the solution is a dictionary with about 8 thousand entries, which is not that much for Plover. I do agree that ideally, we'd have this as a Plover feature, but I explicitly mention in the post that this is a work around until it is integrated into Plover.