0

I built a calculator in WPF and would like to bind my keyboard keys to it. Here is how I bind the NumPad0 key to my command. I'd also like to use D0 key to accomplish the same.

<Window.InputBindings>
    <KeyBinding Command="{Binding AddCharacterCommand}" 
                CommandParameter="0" Key="NumPad0"/>
</Window.InputBindings>
alegz
  • 133
  • 1
  • 13
  • 1
    Did you try adding another `KeyBinding`? – dkozl Dec 31 '15 at 10:31
  • Haven't thought about that, thanks! – alegz Dec 31 '15 at 10:36
  • Any idea how I can access the "/" key on alfanumeric keyboard? this works for numpad only. – alegz Dec 31 '15 at 10:48
  • If you want to get the actual produced character then you will need to resort to some Win32Api calls to get the character behind the virtual key code. See http://stackoverflow.com/questions/318777/c-sharp-how-to-translate-virtual-keycode-to-char for reference. – Janne Matikainen Dec 31 '15 at 11:51

1 Answers1

0

Did you tried this?

<Window.InputBindings>
    <KeyBinding Command="{Binding AddCharacterCommand}" 
                CommandParameter="0" Key="NumPad0,D0"/>
</Window.InputBindings>