Daniel Szabo
Daniel Szabo

Reputation: 7281

Sublime Text 3 Special Character Keybinding

I'm trying to figure out how to use the 'asterisk' key on my number pad in a keybinding.

This does not work:

[{"keys": ["ctrl+*"], "command": "align_tab","args" : {"user_input" : "=/f"}}]

I've tried other key combinations with success (ctrl+8, cntrl+9, etc) but for some reason I cannot get the asterisk key to fire the command. Any suggestions?

Thanks!

Upvotes: 0

Views: 360

Answers (2)

Daniel Szabo
Daniel Szabo

Reputation: 7281

Of course, moments after I post the question I figure it out.

In order to see the key event associated with each key, type the following into the Sublime console (ctrl+`):

sublime.log_input(True)
sublime.log_commands(True)

This will show you the character and key events for each key press. A little experimenting showed me that the numberpad characters are referenced by "keypad_{operator}".

So, to use the asterisk, the proper keybinding is "keypad_multiply".

The solution to my original problem is:

"keys": ["ctrl+keypad_multiply"], "command": "align_tab"

EDIT

OR, you could save yourself a ton of trouble and just follow the link in @MattDMo's answer. :)

For the lazy, here's a list of bindable special keypad characters:

  • keypad_period
  • keypad_divide
  • keypad_multiply
  • keypad_minus
  • keypad_plus
  • keypad_enter

Upvotes: 0

MattDMo
MattDMo

Reputation: 102842

If you check the list of bindable keys in the unofficial docs, you'll find that the keypad * key is named keypad_multiply. So, your keybinding should look like this:

[
    {"keys": ["ctrl+keypad_multiply"], "command": "align_tab", "args" : {"user_input": "=/f"} }
]

Upvotes: 2

Related Questions