Sublime Forum

Add key to selection if modifier is down?

#1

ST doesn’t fire events for modifier keys alone apparently, but I’d like to detect when an alpha-numeric key is pressed while alt (must distinguish between left and right alt) is held down, and add it to a selection that I can run further commands on.

I’ve been digging around docs but haven’t found how to do this. Any ideas?

0 Likes

#2

In your plugin, add a Default.sublime-keymap file with lines like this:

{ "keys": "alt+1"], "args": {"key": "alt+1"}, "context": { "key": "setting.your_plugin_is_enabled" }], "command": "your_command" }, { "keys": "alt+2"], "args": {"key": "alt+2"}, "context": { "key": "setting.your_plugin_is_enabled" }], "command": "your_command" } ]

Repeat for all the keys you care about: github.com/lunixbochs/actualvim … ime-keymap

0 Likes

#3

Oh I see, thank you. I was going to do a search plugin similar to this guy, but without press/release events it is impossible.

0 Likes

#4

You could make something like Alt+Letter open a search box with the first letter filled out. Esc would be your release.

0 Likes