System properties for keypad settings

The following system properties are supported in S60 devices:

Table 58: Nokia system properties for keypads

System property

Description

S60 Release

Value

com.nokia.keyboard.type

Gives the type of physical device keyboard as a string.

S60 5th Edition

Returns a variety of potential values. For full details, see table Return values for com.nokia.keyboard.type.

com.nokia.key.scancode

Returns the scan code of last pressed key. For further usage, the return value can be converted using the Integer.parseInt method.

S60 5th Edition

Scan codes are device keyboard driver specific. For S60 Java, the S60 platform scan codes are used directly. For a list of standard scan codes, see Enum TStdScanCode in S60 C++ Developer's Library.

com.nokia.key.modifier

Returns modifier value of last pressed key. For further usage, the return value can be converted using the Integer.parseInt method.

S60 5th Edition

Returns a variety of potential values. For full details, see table Return values for com.nokia.key.modifier.

The return value can carry multiple modifier flags. Bitwise AND comparison between modifier value and mask (from table) can be used to find out which modifier keys were pressed.

Table 59: Return values for com.nokia.keyboard.type

Keyboard layout

String value

No keypad (for example a touch device without keypad)

None

Standard ITU-T keypad (Phone keypad with 12 keys)

PhoneKeypad

QWERTY (4x12 layout)

FullKeyboard

QWERTY (limited, 4x10 layout)

LimitedKeyboard4x10

QWERTY (limited, 3x11 layout)

LimitedKeyboard3x11

Half QWERTY layout (also known as Compact QWERTY keyboard) layout.

Note: In half QWERTY layout, a single key is used to input more than one character. This kind of text input requires the use of tapping or predictive input methods similar to Standard ITU-T keypad (PhoneKeypad)

HalfKeyboard

Custom QWERTY layout

Custom

Unknown layout

Unknown

Table 60: Return values for com.nokia.key.modifier

Modifier key

String value (decimal form)

HEX value

Left Shift

1280

0x00000500

Right Shift

1536

0x00000600

Left Ctrl

160

0x000000A0

Right Ctrl

192

0x000000C0

Fn

12288

0x00003000

Chr

10240

0x00002800

Example

The following example shows you how to use the system properties from the above tables. This example contains code snippets that are inserted in various parts of the target MIDlet. The used Canvas is assumed to have the name TestCanvas.

First, declare the initial variables and constants. The first six values are from table Return values for com.nokia.key.modifier.

private static final int LSHIFT = 0x00000500;
private static final int RSHIFT = 0x00000600;
private static final int LCTRL  = 0x000000A0;
private static final int RCTRL  = 0x000000C0;
private static final int FN     = 0x00003000;
private static final int CHR    = 0x00002800;

int keyCode;
int keyScanCode = 0;
int keyModifiers = 0;
String keyboard = “”;
String modifier = “”;

To process the output values from the system properties, insert the following lines into the keyPressed() method:

this.keyCode = 0;
this.keyScanCode = 0;
this.keyModifiers = 0;
        
this.keyCode = keyCode; //keyCode is argument of keyPressed method
        
try {
	this.keyScanCode = Integer.parseInt(System.getProperty("com.nokia.key.scancode"));
	this.keyModifiers = Integer.parseInt(System.getProperty("com.nokia.key.modifier"));
}
	catch (NumberFormatException e) {
	e.printStackTrace();
}
     
//if keyModifiers value contains some of modifier bits, 
//name of corresponding key is added to modifier string  
this.modifier = "";
this.modifier += ((this.keyModifiers & TestCanvas.LSHIFT) == TestCanvas.LSHIFT) ? "LSHIFT " : ""; 
this.modifier += ((this.keyModifiers & TestCanvas.RSHIFT) == TestCanvas.RSHIFT) ? "RSHIFT " : "";
this.modifier += ((this.keyModifiers & TestCanvas.FN) == TestCanvas.FN) ? "FN " : "";
this.modifier += ((this.keyModifiers & TestCanvas.CHR) == TestCanvas.CHR) ? "CHR " : "";
        
this.keyboard = System.getProperty("com.nokia.keyboard.type");

To print the current values on screen, add the following lines inside the paint() method:

g.setColor(0xffffffff);
g.fillRect(0, 0, this.getWidth(), this.getHeight());
        
Font f = g.getFont();
        
g.setColor(0xff000000);
        
g.drawString("Keyboard: " + this.keyboard, 0, 0 + f.getHeight()*0, Graphics.TOP | Graphics.LEFT);
g.drawString("Key code: " + this.keyCode, 0, 0 + f.getHeight()*1, Graphics.TOP | Graphics.LEFT);
g.drawString("Scan code: " + this.keyScanCode, 0, 0 + f.getHeight()*2, Graphics.TOP | Graphics.LEFT);
g.drawString("Modifier: " + this.keyModifiers, 0, 0 + f.getHeight()*3, Graphics.TOP | Graphics.LEFT);
g.drawString("Modifiers: " + this.modifier, 0, 0 + f.getHeight()*4, Graphics.TOP | Graphics.LEFT);
g.drawString("Character: " + (char)this.keyCode, 0, 0 + f.getHeight()*5, Graphics.TOP | Graphics.LEFT);