Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the Silverlight keycode for a dash "-"

Tags:

silverlight

I've tried Key.Subtract but I think that is the numpad version. I'm looking for the one after the zero key.

I wish to handle it in a KeyDown event.

Thanks

like image 553
user169867 Avatar asked Dec 20 '25 08:12

user169867


1 Answers

A quick debug shows the that it comes through as Key.Unknown as do other keys such as [ and ]

So it looks like you can't (easily) distinguish when this key is pressed.

The MSDN page for System.Windows.Input.Key enumeration lists all the values, which is significantly shorter than the .NET framework version.

However, if you look at e.PlatformKeyCode this might give you the value you need. However, the help for this states:

This value is the nonportable key code, which is operating system–specific.

The remarks are more extensive:

The portable key codes are a common subset of all the possible key codes of the supported operating systems, in this case, Macintosh and Windows. For example, the keystroke 'v' is represented as a Key value (which would evaluate as 51 if you cast it to an integer, but is more useful if you retain the enumeration information). That key would have a PlatformKeyCode value of 86. Certain keystrokes, however, are not portable, such as the SCROLL LOCK key for Microsoft Windows. In this case, the Key value is Unknown, which is the value for any nonportable key, and the PlatformKeyCode is 145 on a Windows platform. For information about Microsoft Windows-specific key codes, see "Virtual-Key Codes" in the MSDN Library. For information on Macintosh-specific key codes, see Keyboard Layout Services Reference (broken link removed) on the Apple Developer Connection Web site.

On my setup (Chrome in Windows XP) "-" is 189

like image 82
ChrisF Avatar answered Dec 23 '25 09:12

ChrisF



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!