Key chord support
Is your feature request related to a problem?
In some editors (for example emacs) it is possible to bind actions not just to key shortcuts, but to key chords. A key chord is a press of two non-modifier buttons at the same time. For example, you can bind pressing x c to perform some common action (save the file, search for a file, autocomplete the current word, etc.). Usually, you'd press the two buttons with two fingers at the same time.
It is extremely useful because it allows to perform actions without changing modes and without reaching for a modifier. The actions then become part of the typing experience.
As an example, one of the most commonly used key chords that I have is ., (I'm using Dvorak, in Qwerty that'd be we, just so that you understand the key placement). In emacs I have it set to dabbrev-expand which autocompletes the word based on anything it has seen so far. If I have a class called HelloWorld, then typing H e ., (imagine typing H e we on Qwerty) immediately gives me HelloWorld. Out of all ways of doing auto completion, I have never seen anything that'd be as efficient, ergonomic and just overall useful.
The way it's implemented is that whenever you type any character that is part of a key chord, it will be held back for a certain timeout/delay (≈200ms). That character will be entered:
- if the timeout is reached
- or if the user typed another character that doesn't form a key chord
Note that the delay is only applied to characters that are part of configured key chords, so the rest of the typing experience is not affected.
Some notes:
- In Emacs, this introduces a visible delay whenever you type any character that is part of a configured key chord.
- Yes, certain key chords are not practical if the involved characters often form a digraph (example:
heis a terrible choice for a key chord because you'll keep triggering it by accident when typing “hello”). But no worries, turns out there are lots of character combinations that you'll never type in your life. - Realistically, not a lot of people use it. Such a pity!
Describe the solution you'd like
I think Zed is in a unique situation wrt key chord support because it can actually remove the visual delay. From what I understand, because Zed takes control of the entire stack, it should be possible to “draw” the typed character without actually entering it. This way, typing can be instantaneous and fluid even if the user has certain key chords configured.
See https://github.com/zed-industries/feedback/discussions/369#discussioncomment-3212115 for some thoughts on this.
@kevinsjoberg yeah, but key chords are different from layers. When you press a key chord, you're left at the same layer. And the keys can be pressed in any order. It's basically a way to have a shortcut without using any modifiers, without using modes and without interrupting your normal flow of typing.