Home Download Buy Blog Forum Support

Add key to selection if modifier is down?

Add key to selection if modifier is down?

Postby vonWolfehaus on Sun Nov 03, 2013 3:18 am

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?
vonWolfehaus
 
Posts: 2
Joined: Sun Nov 03, 2013 3:13 am

Re: Add key to selection if modifier is down?

Postby lunixbochs on Sun Nov 03, 2013 7:05 pm

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

Code: Select all
[
    { "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: https://github.com/lunixbochs/actualvim ... ime-keymap
lunixbochs
 
Posts: 91
Joined: Fri Oct 08, 2010 10:18 pm

Re: Add key to selection if modifier is down?

Postby vonWolfehaus on Sun Nov 03, 2013 7:37 pm

lunixbochs wrote:In your plugin, add a Default.sublime-keymap file with lines like this: [...] Repeat for all the keys you care about: https://github.com/lunixbochs/actualvim ... ime-keymap


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.
vonWolfehaus
 
Posts: 2
Joined: Sun Nov 03, 2013 3:13 am

Re: Add key to selection if modifier is down?

Postby lunixbochs on Sun Nov 03, 2013 8:21 pm

You could make something like Alt+Letter open a search box with the first letter filled out. Esc would be your `release`.
lunixbochs
 
Posts: 91
Joined: Fri Oct 08, 2010 10:18 pm


Return to Plugin Development

Who is online

Users browsing this forum: BugFix and 4 guests