Hot to recognize the space button!

Hi, I had to made a customItem, in fact a TextField. Now I have managed to get theinput from the user and made an algoryth to write and everything. Now the problem is this one:

I can have numbers, letters and spaces on my TextField, with numbers and letters is easy, but with spaces I just cant know where the device has the space symbol asigned. on nokia devices is on the 0, but on other cell phones its on another button.

Please help me with this.

[469 byte] By [MelGohana] at [2007-11-27 6:28:45]
# 1

you'll have to include some kind of "device key map" as a resource in the app, so that you can look up what that particular phone uses for it's space key.

for example, maybe you have a file in your jar called "key.map"

device.key.space: 0

device.key.left_soft: -6

device.key.right_soft: -7

device.key.clear: -8

you can figure out the parsing of the file and such, but, wrap it all up in a nice utility class like:

public class KeyUtil {

public boolean isKey(String keyname, int keycode) {

// use keyname to look up "device.key.space"

// and if keycode matches the value of device.key.space

// return true!

// else return false

}

}

just a quick pseudo-code example for ya

pandora_fooa at 2007-7-12 17:52:16 > top of Java-index,Java Mobility Forums,Java ME Technologies...
# 2

just for example, in your canvas, you might have:

public void keyPressed(int key) {

if (KeyUtil.isKey("device.key.space", key)) {

System.out.println("space pressed!");

}

else if (KeyUtil.isKey("device.key.left_soft", key) {

System.out.println("left softkey pressed!");

}

}

there ya go :)

ps- forgot to make isKey() static in my last post

pandora_fooa at 2007-7-12 17:52:16 > top of Java-index,Java Mobility Forums,Java ME Technologies...