Skip to content

Chained Keybinds #9961

@mitchellh

Description

@mitchellh

Discussion: #3175 (Lots of context!)

The ability to register a keybind with multiple actions that happen in sequence.

Every syntax I can think of complicates parsing binding actions which by this point can contain just about anything. So, instead, I thought of something different. Here is some proposed syntax:

keybind = ctrl+shift+f=ignore
keybind = chain=toggle_fullscreen
keybind = chain=toggle_window_decorations

The chain key would cause the parsed action to be appended to the most recently bound action. Therefore, starting with ignore is a good way to ensure that you're starting a new chain and to establish the key. You could just as easily start with toggle_fullscreen here. The chain will inherit the flags of the most recently bound action (performable, all, global, etc.).

Note that chaining will NOT work with unbind. Unbind explicitly removes a binding so chaining cannot attach to it.

This adds a bit of verbosity but enables a bunch of good use cases for us:

  • Doesn't complicate parsing actions, there's no ambiguity, quotations, escapes, etc. needed to support this.
  • chain makes it pretty clear something special is going on. I thought about using a sigil like | or |> or something but that makes it pretty special. chain is pretty clear, I think.
  • Compatible with CLIs without ugly quoting, --keybind=ctrl+shift+f=unbind --keybind=chain=foo --keybind=chain=bar
  • Easy to make it a configuration error to specify any flags on chains

I know its not ideal and the syntax is a bit odd at first glance, but I think its the best option we've got given the constraints.

Metadata

Metadata

Assignees

No one assigned

    Labels

    inputKeyboard or mouse input

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions