Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow multi-key keybinds #1420

Closed
pjz opened this issue Jan 31, 2024 · 9 comments · Fixed by #2121
Closed

Allow multi-key keybinds #1420

pjz opened this issue Jan 31, 2024 · 9 comments · Fixed by #2121

Comments

@pjz
Copy link
Collaborator

pjz commented Jan 31, 2024

Currently all keybinds must be one single 'chord'.

I'd like support for a key sequence - that is, multiple keys pressed in a row.

This would allow me to emulate tmux/screen's keybindings

@gegoune
Copy link
Collaborator

gegoune commented Jan 31, 2024

That sounds similar to Wezterm's key_tables.

@pjz
Copy link
Collaborator Author

pjz commented Feb 5, 2024

Point of reference: Kitty uses > to denote a sequence. Eg. ctrl+b>c is ctrl-b followed by the letter c.

@mitchellh
Copy link
Contributor

I approve of the > syntax for sequences.

@pjz
Copy link
Collaborator Author

pjz commented Feb 13, 2024

As discussed on discord, we don't have to have a timeout for the leader keys, which makes this significantly easier.

While @mitchellh has experience that vim does a timeout, none of tmux, screen, or kitty do - they seem to wait forever once the leader is pressed to see if it completes a keybind.

A keybind can be built to emit the leader, like: ctrl+a>a=ctrl+a or if that's confusing perhaps ctrl+a>a=text:\x01

A max sequence length (perhaps four, to keep emacs people happy?) should be put into a const in input/Binding.zig and use it in Surface.zig. The binding trigger parse code needn't use a statically allocated array but it can check if someone tries to do more than the max and error.

@bentay
Copy link
Collaborator

bentay commented Feb 13, 2024

This issue is the only reason I still use tmux inside of Ghostty on my daily driver. Would love to have it! :)

@mitchellh mitchellh added this to the 1.0 Public Release milestone Jul 8, 2024
@mitchellh
Copy link
Contributor

From Discord, more details:

  • If you define a bunch of sequences like ctrl+a>... and then do keybind = ctrl+a=scroll_up, all previous sequences are deleted.
  • If you define a sequence ctrl+a>b and then type ctrl+a>c, then the encoded input for all leaders up to the final are sent to the pty.
  • We should have some visual indication we're in the middle of sequence. A proposal was a URL-style overlay showing the currently pending sequence.

@mitchellh
Copy link
Contributor

mitchellh commented Aug 15, 2024

I've started working on this, and I've realized one downside of the already approved > syntax is that it requires quoting on the command line, which is potentially unfortunate. ☹️ First person to recommend a unicode arrow like → is uninvited from the beta. 🤣

For now I'm going to carry on with > because its very very easy to change this later (before merge at least), but I wanted to post this comment in case anyone had any other thoughts.

@nfejzic
Copy link
Contributor

nfejzic commented Aug 15, 2024

one downside of the already approved > syntax is that it requires quoting on the command line

Would a comma work well? Something like ctrl+a,b. Comma would nicely indicate a (short) pause between different key combos.

@mitchellh
Copy link
Contributor

PR is up #2121.

The sequenced keybind PR somewhat dramatically overhauls how we do binding handling so even if you don't use sequences, I'd love if some folks who are comfortable building from source can bash on that PR a bit and see if they see anything wonky.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants