Displaying the touch screen keyboard

A BlackBerry® device user can use the touch screen keyboard to perform actions such as typing an email message or typing a phone number.

The user can control when the BlackBerry device displays the touch screen keyboard. You can also programmatically control when the BlackBerry device displays the touch screen keyboard. You must create an instance of the net.rim.device.api.ui.Screen class or one of the subclasses of the Screen class and use the Screen.getVirtualKeyboad() method to retrieve an object of the net.rim.device.api.ui.VirtualKeyboard class. The VirtualKeyboard class contains methods and constants that enable a BlackBerry device application to work with the touch screen keyboard.

You can use the VirtualKeyboard.isSupported() method to enable a BlackBerry device application to determine whether the BlackBerry device supports a touch screen keyboard. If VirtualKeyboard.isSupported() returns the value true, the BlackBerry device supports a touch screen keyboard.

A BlackBerry device user might need to use the touch screen keyboard only to perform certain actions. A user might also need to use the touch screen keyboard the entire time the application is open. You can enable a BlackBerry device application to hide or display the touch screen keyboard by invoking the VirtualKeyboard.setVisibility() method with one of the constants from the Virtualkeyboard class as a parameter. For example, you can display the touch screen keyboard on the current screen of the BlackBerry device by invoking VirtualKeyboard.setVisibility(VirtualKeyboard.SHOW). You can hide the touch screen keyboard by invoking VirtualKeyboard.setVisibility(VirtualKeyboard.HIDE).

Code sample: Displaying the touch screen keyboard on the current screen

VirtualKeyboard virtKbd;
MainScreen _screen = new MainScreen( MainScreen.VERTICAL_SCROLL );
virtKbd = _screen.getVirtualKeyboard();
virtKbd.setVisibility(VirtualKeyboard.SHOW);

Was this information helpful? Send us your comments.