Justin
Justin

Reputation: 2479

When are keybinding preferable to handling key-up/key-down (.ect) events?

When are keybinding preferable to handling key-up/key-down (.ect) events?

Upvotes: 3

Views: 653

Answers (1)

Tim C
Tim C

Reputation: 1934

I think this entirely depends on your needs. Keybindings have some restrictions which event handlers do not. For example, with a keybinding you must have a key and a key modifier (unless you are using the function keys or the number pad keys). Additionally, if I remember correctly, you can't catch just the keydown event with keybinding.

So let's say you have a "repeat" function that you want to have happen when someone types a certain set of keys. Keybinding would allow you to quickly bind this function to the R+Alt key combination.

If on the other hand you wanted to set off the repeat function every time someone key-down only the R key but then do another function when the R key is released (key-up), you would need to use Event Handlers.

Upvotes: 4

Related Questions