SHOW Signed
 

net.rim.device.api.system
Class EventInjector.KeyCodeEvent

java.lang.Object
  |
  +--net.rim.device.api.system.EventInjector.Event
        |
        +--net.rim.device.api.system.EventInjector.KeyCodeEvent
Enclosing class:
EventInjector

public static class EventInjector.KeyCodeEvent
extends EventInjector.Event

The event class that defines a physical key press event.

Use this class to create events that mimic an actual key being pressed on the device. This class may come in handy when the actual key pressed (and not the character that may result from the key being pressed) is important (i.e. injecting keyboard shortcuts, etc.).

It is recommended to inject a KEY_DOWN event followed by a KEY_UP event on the same key to more accurately emulate keyboard use, although this may not always be necessary.

This is a more powerful event class than KeyEvent, but more difficult to use because application behaviour depends on the context when the key is invoked. For example, if you inject the 'X' key on a device with a QWERTY keyboard in the phone application, the number 8 will be dialed. If you inject in a compose screen, the letter "x" will be output on the screen.

To inject actual characters (for typing, etc.), use EventInjector.KeyEvent.

Category:
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.

Since:
JDE 4.2.0
See Also:
EventInjector, EventInjector.Event, EventInjector.TrackwheelEvent, EventInjector.KeyEvent, EventInjector.NavigationEvent

Field Summary
 Category: Signed static int KEY_DOWN
          Represents a constant indicating that the key is in the down position.
 Category: Signed static int KEY_REPEAT
          Represents a constant indicating that the key is in the down position, repeating the character.
 Category: Signed static int KEY_UP
          Represents a constant indicating that the key is in the up position.
   
Constructor Summary
 Category: Signed EventInjector.KeyCodeEvent(int event, char keyName, int status)
          Constructs a new KeyCodeEvent instance whose time is set to the current device uptime.
 Category: Signed EventInjector.KeyCodeEvent(int event, char keyName, int status, int time)
          Deprecated. Use KeyCodeEvent(int, char, int) instead.
 
Method Summary
 Category: Signed  int getKeyCode()
          Gets the keycode injected by this event
 Category: Signed  int getStatus()
          Returns the status.
 Category: Signed  int getTime()
          Returns the time of the event.
 Category: Signed  void setKeyCode(char keyName, int status)
          Set the keycode injected by this event.
 Category: Signed  void setStatus(int status)
          Sets the status of a key.
 Category: Signed  void setTime(int time)
          Deprecated. Use EventInjector.Event.setTimeToCurrent() instead.
 
Methods inherited from class net.rim.device.api.system.EventInjector.Event
getEvent, post, setEvent, setTimeToCurrent
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

KEY_DOWN

public static final int KEY_DOWN
Represents a constant indicating that the key is in the down position.
Since:
JDE 4.2.0
Category:
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.

KEY_REPEAT

public static final int KEY_REPEAT
Represents a constant indicating that the key is in the down position, repeating the character.
Since:
JDE 4.2.0
Category:
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.

KEY_UP

public static final int KEY_UP
Represents a constant indicating that the key is in the up position.
Since:
JDE 4.2.0
Category:
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
Constructor Detail

EventInjector.KeyCodeEvent

public EventInjector.KeyCodeEvent(int event,
                                  char keyName,
                                  int status)
Constructs a new KeyCodeEvent instance whose time is set to the current device uptime.
Parameters:
event - One of KEY_DOWN, KEY_REPEAT or KEY_UP.
keyName - The name of the key pressed. Keys are named as follows:

On a QWERTY keyboard, the name of the key is the Latin alphabetic character that appears on it (Q, W, E, etc.) or one of the KEY constants defined in Keypad cast to a char.

On a reduced QWERTY keyboard, the name of the key is the leftmost Latin alphabetic character that appears on it (Q, E, T, etc.) or one of the KEY constants definded in Keypad cast to a char.

status - Any status flags except STATUS_TRACKWHEEL and STATUS_FOUR_WAY (as defined by KeypadListener).
Throws:
IllegalArgumentException - if status is invalid
Since:
JDE 4.5.0
Category:
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.

EventInjector.KeyCodeEvent

public EventInjector.KeyCodeEvent(int event,
                                  char keyName,
                                  int status,
                                  int time)
Deprecated. Use KeyCodeEvent(int, char, int) instead.

Constructs a new KeyCodeEvent instance whose time is set to the current device uptime.
Parameters:
event - One of KEY_DOWN, KEY_REPEAT or KEY_UP.
keyName - The name of the key pressed. Keys are named as follows:

On a QWERTY keyboard, the name of the key is the Latin alphabetic character that appears on it (Q, W, E, etc.) or one of the KEY constants defined in Keypad cast to a char.

On a reduced QWERTY keyboard, the name of the key is the leftmost Latin alphabetic character that appears on it (Q, E, T, etc.) or one of the KEY constants definded in Keypad cast to a char.

status - Any status flags except STATUS_TRACKWHEEL and STATUS_FOUR_WAY (as defined by KeypadListener).
time - No longer used. Time is set to the current device uptime.
Throws:
IllegalArgumentException - if status is invalid
Since:
JDE 4.2.0
Category:
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
Method Detail

getKeyCode

public int getKeyCode()
Gets the keycode injected by this event
Returns:
The keycode
Since:
JDE 4.2.0
Category:
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.

getStatus

public int getStatus()
Returns the status.

Overrides:
getStatus in class EventInjector.Event
Returns:
An integer representing the status.
Since:
JDE 4.3.0
Category:
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.

getTime

public int getTime()
Description copied from class: EventInjector.Event
Returns the time of the event.

Overrides:
getTime in class EventInjector.Event
Since:
JDE 4.2.0
Category:
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.

setKeyCode

public void setKeyCode(char keyName,
                       int status)
Set the keycode injected by this event. If the keycode is CONTROL_xxxx (as defined in Characters), then Status is reset.
Parameters:
keyName - The name of the key pressed (see constructor for notes).
status - Status of the key. See constructor for valid statuses.
Throws:
IllegalArgumentException - If status is invalid.
Since:
JDE 4.2.0
Category:
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.

setStatus

public void setStatus(int status)
Sets the status of a key. The KeyCode remains the same.

Overrides:
setStatus in class EventInjector.Event
Parameters:
status - An integer representing the status of the key. See constructor for valid statuses.
Throws:
IllegalArgumentException - If status is invalid.
Since:
JDE 4.3.0
Category:
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.

setTime

public void setTime(int time)
Deprecated. Use EventInjector.Event.setTimeToCurrent() instead.

Sets the time of this event to the current device uptime.

Parameters:
time - No longer used. Time is set to the current device uptime.
Since:
JDE 4.2.0
Category:
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.



Copyright 1999-2009 Research In Motion Limited. 295 Phillip Street, Waterloo, Ontario, Canada, N2L 3W8. All Rights Reserved.
Copyright 1993-2003 Sun Microsystems, Inc. 901 San Antonio Road, Palo Alto, California, 94303, U.S.A.
Copyright 2002-2003 Nokia Corporation All Rights Reserved.
Java is a trademark or registered trademark of Sun Microsystems, Inc. in the US and other countries.