rams
rams

Reputation: 6791

How to determine the value of key pressed in Windows Phone 7 Numeric Keyboard?

I hooked up an event handler to the KeyDown event of a TextBox. The event handler has an argument of type KeyEventArgs with properties Key and PlatformKeyCode. The issue is for both the 1 and ! keys pressed on the windows phone soft keyboard, the values for Key and PlatformKeyCode are D1 and 49 respectively. I cant tell which key was pressed. Also the Keyboard.Modifiers static property returns "None"

So how do I determine the key that was pressed?

Upvotes: 5

Views: 1229

Answers (2)

Matt Lacey
Matt Lacey

Reputation: 65564

This very much looks like a bug.

This exists on both the emulator and real devices.

If using the pc keyboard with the emulator the modifier keys are detected on key down so this won't work.

Interestingly, if using a device with a physical keyboard, if the function/shift button is enabled it triggers 2 keydown events when the other button is pressed. One for the correct keycode and one for the modifier key but Keboard.Modifier always equals "None".

It looks like you need to read the textbox value before and after the TextChanged event.

Upvotes: 1

Mick N
Mick N

Reputation: 14882

This is a known issue.

KeyDown/OnKeyDown and KeyUp/OnKeyUp issues

You could always read the input values instead and act on 1 / ! seperately.

Upvotes: 2

Related Questions