WPF Multiple Key Binding

How can I execute some command, say Ctrl + Shift + E? As I saw, we can write the following:

KeyBinding kb = new KeyBinding(TestCommand, Key.E, ModifierKeys.Control);
this.InputBindings.Add(kb);

      


But how can I add more modifiers or keys?

+2


a source to share


1 answer


ModifiedKeys

is an enumeration of flags, so you can combine your values ​​with the boolean OR ( |

) operator like this:



KeyBinding kb = new KeyBinding(TestCommand, Key.E, ModifierKeys.Control | ModifierKeys.Shift);
this.InputBindings.Add(kb);

      

+4


a source







All Articles