Skip to main content

How to catch alphabetical key events

5 replies [Last post]
digitalsol
Offline
Joined: 2009-10-11
Points: 0

Hello,

how can I catch key events from QWERTY keyboard for concrete abc keys ? Currently I use CANVAS.KEY_NUM#, but I'm wondering how can I catch a key press on the "a" key for example.

Regards

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
vprise
Offline
Joined: 2003-11-07
Points: 0

Cast the int of the keyCode to char it will map to the numerics/characters as you would expect depending on the device type (keypad or qwerty).

digitalsol
Offline
Joined: 2009-10-11
Points: 0

Ah, thank you. This fixes my problem.

Best Regards

Mixa

It is not fully supported by MIDP. Implementations may provide that
info via Canvas.getKeyName().

Regards,
Mike

On Tue, Mar 9, 2010 at 7:57 PM, wrote:
> Hello,
>
> how can I catch key events from QWERTY keyboard for concrete abc keys ? Currently I use CANVAS.KEY_NUM#, but I'm wondering how can I catch a key press on the "a" key for example.
>
> Regards
> [Message sent by forum member 'digitalsol' (digitalsol@abv.bg)]
>
> http://forums.java.net/jive/thread.jspa?messageID=390896
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@lwuit.dev.java.net
> For additional commands, e-mail: users-help@lwuit.dev.java.net
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@lwuit.dev.java.net
For additional commands, e-mail: users-help@lwuit.dev.java.net

digitalsol
Offline
Joined: 2009-10-11
Points: 0

Thank you.
But how can I get the Canvas object

Mixa

I do not know how to retrieve Canvas instance via LWUIT API normally -
Display has method getImplementation() but it is not visible (I
changed it to public in my copy of LWUIT).

I think you could create your own Canvas instance
Canvas canvas = new Canvas()
and check key codes against it

Also current Displayable object (which is GameCanvas for basic LWUIT
implementation) via MIDP
Canvas canvas = (Canvas)Display.getDisplay(your_midlet).getCurrent();

3rd way is to create new LWUITImplementation class extending current
LWUIT GameCancasImplementation exposing getCanvas() method which is
protected.

Mike

On Wed, Mar 10, 2010 at 3:52 PM, wrote:
> Thank you.
> But how can I get the Canvas object
> [Message sent by forum member 'digitalsol' (digitalsol@abv.bg)]
>
> http://forums.java.net/jive/thread.jspa?messageID=391027
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@lwuit.dev.java.net
> For additional commands, e-mail: users-help@lwuit.dev.java.net
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@lwuit.dev.java.net
For additional commands, e-mail: users-help@lwuit.dev.java.net