Packages
 In this topic

*Constructors

*Methods

*Fields

 

Packages   PreviousThis PackageNext
Package com.ms.ui.event   Previous This
Package
Next

 


Class UIKeyEvent

public class UIKeyEvent extends UIInputEvent
{
  // Fields
  public static final char CHAR_UNDEFINED;
  public static final int KEY_EVENT_BASE;
  public static final int KEY_PRESSED;
  public static final int KEY_RELEASED;
  public static final int KEY_TYPED;
  public static final int VK_0;
  public static final int VK_1;
  public static final int VK_2;
  public static final int VK_3;
  public static final int VK_4;
  public static final int VK_5;
  public static final int VK_6;
  public static final int VK_7;
  public static final int VK_8;
  public static final int VK_9;
  public static final int VK_A;
  public static final int VK_ACCEPT;
  public static final int VK_ADD;
  public static final int VK_ALT;
  public static final int VK_B;
  public static final int VK_BACK_QUOTE;
  public static final int VK_BACK_SLASH;
  public static final int VK_BACK_SPACE;
  public static final int VK_C;
  public static final int VK_CANCEL;
  public static final int VK_CAPS_LOCK;
  public static final int VK_CLEAR;
  public static final int VK_CLOSE_BRACKET;
  public static final int VK_COMMA;
  public static final int VK_CONTROL;
  public static final int VK_CONVERT;
  public static final int VK_D;
  public static final int VK_DECIMAL;
  public static final int VK_DELETE;
  public static final int VK_DIVIDE;
  public static final int VK_DOWN;
  public static final int VK_E;
  public static final int VK_END;
  public static final int VK_ENTER;
  public static final int VK_EQUALS;
  public static final int VK_ESCAPE;
  public static final int VK_F;
  public static final int VK_F1;
  public static final int VK_F10;
  public static final int VK_F11;
  public static final int VK_F12;
  public static final int VK_F2;
  public static final int VK_F3;
  public static final int VK_F4;
  public static final int VK_F5;
  public static final int VK_F6;
  public static final int VK_F7;
  public static final int VK_F8;
  public static final int VK_F9;
  public static final int VK_FINAL;
  public static final int VK_G;
  public static final int VK_H;
  public static final int VK_HELP;
  public static final int VK_HOME;
  public static final int VK_I;
  public static final int VK_INSERT;
  public static final int VK_J;
  public static final int VK_K;
  public static final int VK_KANA;
  public static final int VK_KANJI;
  public static final int VK_L;
  public static final int VK_LEFT;
  public static final int VK_M;
  public static final int VK_META;
  public static final int VK_MODECHANGE;
  public static final int VK_MULTIPLY;
  public static final int VK_N;
  public static final int VK_NONCONVERT;
  public static final int VK_NUM_LOCK;
  public static final int VK_NUMPAD0;
  public static final int VK_NUMPAD1;
  public static final int VK_NUMPAD2;
  public static final int VK_NUMPAD3;
  public static final int VK_NUMPAD4;
  public static final int VK_NUMPAD5;
  public static final int VK_NUMPAD6;
  public static final int VK_NUMPAD7;
  public static final int VK_NUMPAD8;
  public static final int VK_NUMPAD9;
  public static final int VK_O;
  public static final int VK_OPEN_BRACKET;
  public static final int VK_P;
  public static final int VK_PAGE_DOWN;
  public static final int VK_PAGE_UP;
  public static final int VK_PAUSE;
  public static final int VK_PERIOD;
  public static final int VK_PRINTSCREEN;
  public static final int VK_Q;
  public static final int VK_QUOTE;
  public static final int VK_R;
  public static final int VK_RIGHT;
  public static final int VK_S;
  public static final int VK_SCROLL_LOCK;
  public static final int VK_SEMICOLON;
  public static final int VK_SEPARATER;
  public static final int VK_SHIFT;
  public static final int VK_SLASH;
  public static final int VK_SPACE;
  public static final int VK_SUBTRACT;
  public static final int VK_T;
  public static final int VK_TAB;
  public static final int VK_U;
  public static final int VK_UNDEFINED;
  public static final int VK_UP;
  public static final int VK_V;
  public static final int VK_W;
  public static final int VK_X;
  public static final int VK_Y;
  public static final int VK_Z;

  // Constructors
  public UIKeyEvent(IUIComponent source, int id, long when,
        int modifiers, int keyCode, char keyChar);

  // Methods
  public char getKeyChar();
  public int getKeyCode();
  public boolean isActionKey();
  public String paramString();
}

This class generates IUIComponent keyboard events.

The Virtual key codes report which keyboard key has been pressed, rather than any character generated by one or more keys being pressed.

For example, pressing the SHIFT key causes a KEY_PRESSED event with a VK_SHIFT keyCode, and pressing the A key results in a VK_A keyCode. After the A key is released, a KEY_RELEASED event will be fired with VK_A, followed by a KEY_TYPED event with a keyChar value of "A." Key combinations that do not result in characters (such as action keys like F1) will not generate KEY_TYPED events.

EventObject
  |
  +--UIBaseEvent
    |
    +--UIEvent
      |
      +--UIInputEvent
        |
        +--UIKeyEvent

Constructors

UIKeyEvent

public UIKeyEvent(IUIComponent source, int id, long when, int modifiers,
        int keyCode, char keyChar);

Creates a UIKeyEvent object with the specified source IUIComponent, type, modifiers, and key.

ParameterDescription
source The object where the event originated.
id The event type.
when The time the event occurred.
modifiers The modifier keys down during the event.
keyCode The integer code representing the key of the event.
keyChar Either the Unicode character generated by the event or NULL.

Methods

getKeyChar

public char getKeyChar();

Retrieves the character associated with the key in this event. If no valid Unicode character exists for this key event, keyChar is CHAR_UNDEFINED.

Return Value:

Returns the keyChar of the key that generated the event.

getKeyCode

public int getKeyCode();

Retrieves the integer key code associated with the key in the event. For KEY_TYPED events, the keyCode is VK_UNDEFINED.

Return Value:

Returns the keyCode of the key that generated the event.

isActionKey

public boolean isActionKey();

Determines whether the key in this event is an action key.

Return Value:

Returns true if the key that generated the event is an action key.

paramString

public String paramString();

This method is used internally by the toString method.

Return Value:

Returns a formatted String object that assists with textual representation of the exception.

Fields

CHAR_UNDEFINED
A flag for KEY_PRESSED and KEY_RELEASED events, which do not map to a valid Unicode character.
KEY_EVENT_BASE
The base identifier for all UIKeyEvent events.
KEY_PRESSED
The key pressed event type.
KEY_RELEASED
The key released event type.
KEY_TYPED
The key typed event type, which is generated by a combination of a key press followed by a key release.
VK_0
VK_0 through VK_9 are the same as ASCII "0" through "9" (0x30 - 0x39).
VK_1
A virtual key code for the ASCII "1" key.
VK_2
A virtual key code for the ASCII "2" key.
VK_3
A virtual key code for the ASCII "3" key.
VK_4
A virtual key code for the ASCII "4" key.
VK_5
A virtual key code for the ASCII "5" key.
VK_6
A virtual key code for the ASCII "6" key.
VK_7
A virtual key code for the ASCII "7" key.
VK_8
A virtual key code for the ASCII "8" key.
VK_9
A virtual key code for the ASCII "9" key.
VK_A
VK_A through VK_Z are the same as ASCII "A" through "Z" (0x41 - 0x5A).
VK_ACCEPT
For Asian keyboards.
VK_ADD
A virtual key code for the numeric keypad PLUS SIGN (+) key.
VK_ALT
A virtual key code for the ALT key.
VK_B
A virtual key code for the ASCII "B" key.
VK_BACK_QUOTE
A virtual key code for the apostrophe (`) key.
VK_BACK_SLASH
A virtual key code for the BACKSLASH (\) key.
VK_BACK_SPACE
A virtual key code for the BACKSPACE key.
VK_C
A virtual key code for the ASCII "C" key.
VK_CANCEL
A virtual key code for the CANCEL key.
VK_CAPS_LOCK
A virtual key code for the CAPS LOCK key.
VK_CLEAR
A virtual key code for the CLEAR key.
VK_CLOSE_BRACKET
A virtual key code for the CLOSE BRACKET (]) key.
VK_COMMA
A virtual key code for the COMMA (,) key.
VK_CONTROL
A virtual key code for the CTRL key.
VK_CONVERT
For Asian keyboards.
VK_D
A virtual key code for the ASCII "D" key.
VK_DECIMAL
A virtual key code for the numeric keypad DECIMAL POINT (.) key.
VK_DELETE
A virtual key code for the DELETE key.
VK_DIVIDE
A virtual key code for the numeric keypad DIVISION (/) key.
VK_DOWN
A virtual key code for the DOWN ARROW key.
VK_E
A virtual key code for the ASCII "E" key.
VK_END
A virtual key code for the END key.
VK_ENTER
A virtual key code for the ENTER key.
VK_EQUALS
A virtual key code for the EQUAL SIGN (=) key.
VK_ESCAPE
A virtual key code for the ESC key.
VK_F
A virtual key code for the ASCII "F" key.
VK_F1
A virtual key code for the F1 key.
VK_F10
A virtual key code for the F10 key.
VK_F11
A virtual key code for the F11 key.
VK_F12
A virtual key code for the F12 key.
VK_F2
A virtual key code for the F2 key.
VK_F3
A virtual key code for the F3 key.
VK_F4
A virtual key code for the F4 key.
VK_F5
A virtual key code for the F5 key.
VK_F6
A virtual key code for the F6 key.
VK_F7
A virtual key code for the F7 key.
VK_F8
A virtual key code for the F8 key.
VK_F9
A virtual key code for the F9 key.
VK_FINAL
For Asian keyboards.
VK_G
A virtual key code for the ASCII "G" key.
VK_H
A virtual key code for the ASCII "H" key.
VK_HELP
A virtual key code for the HELP key.
VK_HOME
A virtual key code for the HOME key.
VK_I
A virtual key code for the ASCII "I" key.
VK_INSERT
A virtual key code for the INSERT key.
VK_J
A virtual key code for the ASCII "J" key.
VK_K
A virtual key code for the ASCII "K" key.
VK_KANA
For Asian keyboards.
VK_KANJI
For Asian keyboards.
VK_L
A virtual key code for the ASCII "L" key.
VK_LEFT
A virtual key code for the LEFT ARROW key.
VK_M
A virtual key code for the ASCII "M" key.
VK_META
A virtual key code for the Application key (found on Microsoft® Windows® 95 keyboards).
VK_MODECHANGE
For Asian keyboards.
VK_MULTIPLY
A virtual key code for the numeric keypad MULTIPLICATION (*) key.
VK_N
A virtual key code for the ASCII "N" key.
VK_NONCONVERT
For Asian keyboards.
VK_NUM_LOCK
A virtual key code for the NUM LOCK key.
VK_NUMPAD0
A virtual key code for the numeric keypad "0" key.
VK_NUMPAD1
A virtual key code for the numeric keypad "1" key.
VK_NUMPAD2
A virtual key code for the numeric keypad "2" key.
VK_NUMPAD3
A virtual key code for the numeric keypad "3" key.
VK_NUMPAD4
A virtual key code for the numeric keypad "4" key.
VK_NUMPAD5
A virtual key code for the numeric keypad "5" key.
VK_NUMPAD6
A virtual key code for the numeric keypad "6" key.
VK_NUMPAD7
A virtual key code for the numeric keypad "7" key.
VK_NUMPAD8
A virtual key code for the numeric keypad "8" key.
VK_NUMPAD9
A virtual key code for the numeric keypad "9" key.
VK_O
A virtual key code for the ASCII "O" key.
VK_OPEN_BRACKET
A virtual key code for the OPEN BRACKET ([) key.
VK_P
A virtual key code for the ASCII "P" key.
VK_PAGE_DOWN
A virtual key code for the PAGE DOWN key.
VK_PAGE_UP
A virtual key code for the PAGE UP key.
VK_PAUSE
A virtual key code for the PAUSE (BREAK) key.
VK_PERIOD
A virtual key code for the PERIOD (.) key.
VK_PRINTSCREEN
A virtual key code for the PRINT SCREEN key.
VK_Q
A virtual key code for the ASCII "Q" key.
VK_QUOTE
A virtual key code for the QUOTATION MARK key.
VK_R
A virtual key code for the ASCII "R" key.
VK_RIGHT
A virtual key code for the RIGHT ARROW key.
VK_S
A virtual key code for the ASCII "S" key.
VK_SCROLL_LOCK
A virtual key code for the SCROLL LOCK key.
VK_SEMICOLON
A virtual key code for the SEMICOLON (;) key.
VK_SEPARATER
VK_SHIFT
A virtual key code for the SHIFT key.
VK_SLASH
A virtual key code for the forward slash (/) key.
VK_SPACE
A virtual key code for the SPACEBAR key.
VK_SUBTRACT
A virtual key code for the numeric keypad MINUS SIGN (-) key.
VK_T
A virtual key code for the ASCII "T" key.
VK_TAB
A virtual key code for the TAB key.
VK_U
A virtual key code for the ASCII "U" key.
VK_UNDEFINED
KEY_TYPED events do not have a defined key code.
VK_UP
A virtual key code for the UP ARROW key.
VK_V
A virtual key code for the ASCII "V" key.
VK_W
A virtual key code for the ASCII "W" key.
VK_X
A virtual key code for the ASCII "X" key.
VK_Y
A virtual key code for the ASCII "Y" key.
VK_Z
A virtual key code for the ASCII "Z" key.

upnrm.gif © 1998 Microsoft Corporation. All rights reserved. Terms of use.