Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

c#

wpf

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

like image 882
Justin Avatar asked Jan 20 '26 18:01

Justin


1 Answers

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.

like image 57
Tim C Avatar answered Jan 23 '26 09:01

Tim C