BlackBerry Forums Support Community               

Closed Thread
LinkBack Thread Tools
Old 10-15-2007, 02:44 PM   #1 (permalink)
New Member
Join Date: Dec 2006
Model: 7100T
Carrier: Standard
Posts: 1
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default Keyevent handler in Blackberry

Please Login to Remove!

Hello Everybody,

Until now I developed Symbian OS in C++. So, I'm new in Blackberry. Which class I have to inherit to monitor the device keyevents?
I want to create an application, but I do not want to use the standard menu. I want to create custom menu using my keycodes.

Thank you in advance.
Best regrads,
Old 10-16-2007, 02:51 AM   #2 (permalink)
CrackBerry Addict
Join Date: Apr 2005
Location: hamburg, germany
Model: 8900
Carrier: o2
Posts: 838
Post Thanks: 0
Thanked 0 Times in 0 Posts

implement net.rim.device.api.system.KeyListener

here is an example that works like a numeric input filter extended with some extra:

    public boolean keyChar(char key, int status, int time) {
        boolean retval = false;
        Field field = getLeafFieldWithFocus();
if (field == numberField) {
switch(key) {
                case Characters.LATIN_SMALL_LETTER_W:
                    retval = true;
                    super.keyChar(Characters.DIGIT_ONE, 32768, 0);
                case Characters.LATIN_SMALL_LETTER_E:
                    retval = true;
                    super.keyChar(Characters.DIGIT_TWO, 32768, 0);
//more switches
                if (!retval) super.keyChar(key, status, time);       
        return retval;        
java developer, Devinto, hamburg/germany

Copyright 2004-2016
The names RIM and BlackBerry are registered Trademarks of BlackBerry Inc.