The following system properties are supported in Series 40 and Symbian devices:
System property |
Description |
Series 40 Release |
Symbian Release |
Value |
---|---|---|---|---|
|
Gives the type of physical device keyboard as a string. |
Series 40 6th Edition FP 1 |
S60 5th Edition Note: This property is also supported on newer S60 3rd Edition FP 2 devices. |
Returns a variety of potential values. For full details, see table Return values for com.nokia.keyboard.type. |
|
Returns the scan code of last pressed key. For further usage,
the return value can be converted using the |
Series 40 6th Edition FP 1 |
S60 5th Edition Note: This property is also supported on newer S60 3rd Edition FP 2 devices. |
Scan codes are device keyboard driver specific. For Symbian Java, the Symbian platform scan codes are used directly. For a list of standard scan codes, see Enum TStdScanCode in Symbian C++ Developer's Library. From Series 40 6th Edition Lite onwards, the system property handles QWERTY keyboards similarly to Symbian. |
|
Returns modifier value of last pressed key. For further
usage, the return value can be converted using the |
S60 5th Edition Note: This property is also supported on newer S60 3rd Edition FP 2 devices. |
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 |
Keyboard layout |
String value |
---|---|
No keypad (for example a touch device without keypad) |
|
Standard ITU-T keypad (Phone keypad with 12 keys) |
|
QWERTY (4x12 layout) |
|
QWERTY (limited, 4x10 layout) |
|
QWERTY (limited, 3x11 layout) |
|
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 ( |
|
Custom QWERTY layout |
|
Unknown layout |
|
Modifier key |
String value (decimal form) |
HEX value |
---|---|---|
Left Shift |
|
|
Right Shift |
|
|
Left Ctrl |
|
|
Right Ctrl |
|
|
Fn |
|
|
Chr |
|
|
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);