I have several issues/questions regarding keybinds and input handling. I chose to collect them here since several questions are closely related.
(Context: I’m working on a plugin to do modal editing/navigation on the syntactical level of code using tree-sitter. I have some basic proof-of-concept functionality but I’m starting to encounter more and more frustrations, especially regarding keybind/input.)
1.a) I’ve seen several references to {"keys":["<character>"], ...}
as a catch-all for triggering on regular self-inserted keys. But I cannot find its documentation. Are there other such special keys? (Specifically more expressive/powerful triggers like this <character>
, not simple names like “f12” or “keypad_period”.)
1.b) How do I combine the above behavior but with modifiers? "ctrl+<character>"
, "super+<character>"
, etc. gives me syntax errors.
2.a) More generally, (and ideally,) I would like to run code on all input and choose to react/suppress/ignore/modify it. Is this possible? Basically, I’d like a function to be called with everything that log.input_events(True)
normally prints. Ideally a function which has the option of reporting “I handled it, don’t worry about it” or “I don’t care about this input, you can forward it to other handlers.”
2.b) on_query_context
gets close but it does not seem to receive information about the actual input event that triggered it? Did I miss or misunderstand something there?
(I imagine there exists the option of creating keymaps of several megabytes for thousands of Unicode characters together with all modifier combinations, but that just seems insanely painful and rather silly? My keyboard has several languages and lots of special characters like ∞∅⋆∈∧×⋅∘…
etc…)
3. In my plugin code I would also ideally like to show overlays / certain information when a key is held down. For example like holding down "x"
would show syntactic node type information. Is there a way to trigger on KeyDown/KeyUp events? Currently the only option I see is to either have an on/off toggle, or a “turn on & set a short timeout to turn off,” neither of which is ideal to me.
4. (Linux) Is there a way (e.g. hidden command-line flag) to make Sublime trigger shortcuts by symbol instead of by scancode? For some reason Sublime ignores the symbol (keyval
in GTK) whenever a modifier is involved (if it’s not some basic US QWERTY ASCII), and instead uses the scancode (hardware_keycode
in GTK). This makes zero sense to me (on Linux), and is pretty annoying/confusing. It seems like a Win32-like attempt at “localizing” keys? It matches neither my language nor my keyboard. If I hold down the Control key and type “¿”, it’s because I want to trigger “ctrl+¿”, not whatever this would blindly correspond to on some historic IBM keyboard (Sublime reports “ctrl+q” in this case).)
This also means duplicated ways to input shortcuts that cannot be disambiguated (e.g. both "ctrl+æ"
and "ctrl+altgr+s"
maps redundantly to "ctrl+["
in Sublime) and it means there are several reasonable keybinds I simply cannot input in Sublime even though I can ordinarily type the characters just fine (e.g. "shift+,"
produces ";"
but Sublime interprets "ctrl+shift+,"
literally as itself – and the scancode for the US QWERTY key for semicolon happens to be taken by “o” in my case, thus I seem to have no way of actually triggering a shortcut like "ctrl+;"
).