InputScope property in TextBox and different onscreen keyboard layouts in WinRT

TextBox control is one of the most primitive controls that exists in any Frameworks (e.g., MFC, html, Web Forms). Similar to their predecessors, WPF and Silverlight, WinRT XAML/C# stack also comes with TextBox control. For touch device without physical keyboard, an onscreen keyboard (i.e., soft keyboard) is the main input method to enter text.

An onscreen keyboard is not the easiest thing to type, so a WinRT TextBox control can help by providing allowing developer to specify what type of input is expected via InputScope property. A user will then see different keyboard layouts depending on type of input. However, the InputScope property has nothing to do with validation as it does not prevent users from entering text from other input devices.

The list of available InputScope values can be found from InputScopeNameValue enumeration.

Several notable ones are the followings:

Name Description
Url Input scope is intended for working with a URL.
EmailSmtpAddress Input scope is intended for working with a SMTP form e-mail address (accountname@host).
Number Input scope is intended for working with digits 0-9.
TelephoneNumber Input scope is intended for telephone numbers.
Search Input scope is intended for search strings.

Let’s see them in action.

Url

image

EmailSmtpAddress

image

Number & TelephoneNumber

image

Search

image

In addition, WinRT also provides PasswordBox which gives an extra key, “Hide keypress” while masking the input characters (i.e., password).

image

That’s not all. Windows 8 itself also provides cool split keyboard for thumb typing user as well as letter recognition area if you prefer using pen device.

image

image

Although onscreen keyboard may not be able to replace the real physical keyboard if you have to write a lot (like writing this blog post), providing different keyboard layouts for different type of input can give our users some comfort and make the app easier to use.

Enjoy coding!