Working with Hardware Keyboards (Windows Phone)

XNA Game Studio 4.0

Some, but not all, Windows Phone devices feature hardware keyboards. These keyboards can be accessed using XNA Game Studio in the same manner as hardware keyboards for Xbox 360 or Windows are accessed. There is one major caveat, however, shared by Xbox 360: XNA Game Studio provides no way to determine whether the device has a hardware keyboard, or whether it is currently enabled (open in the case of a slide-style keyboard).

For Windows Phone, the Keys enumeration maps the following members to special keys:

Windows Phone keyKeys enumeration member
Accent keyKeys.F1
Emoticon keyKeys.F2
Symbol keyKeys.F3
Vib keyKeys.F4
Fn keyKeys.LeftShift

All other keys are assigned as described in Keys.

For information about detecting hardware key presses, and for code examples see Detecting a Key Press (Windows, Windows Phone, Xbox 360).

If you are interested in retrieving characters typed—such as when you want text input from the user— instead of the key state, you should use Guide.BeginShowKeyboardInput as described in Displaying a Software Input Panel (Windows Phone, Xbox 360). This process displays a software keyboard that can be used on devices with or without a hardware keyboard, and returns the characters typed.

Community Additions