Class KeyPressedEvent
This event corresponds to the browser's keypress event, which historically fired between keydown and keyup events for printable characters. However, this event type has been deprecated in modern browsers and is no longer recommended for use. Modern applications should use KeyDownEvent instead for detecting key presses. This class is maintained for backward compatibility with legacy code.
Features:
- Historically fired for printable character keys
- Provided character code information
- Deprecated in favor of KeyDownEvent
- Maintained for backward compatibility
Usage: While this event is still supported for backward compatibility, new code should use KeyDownEvent instead. KeyDownEvent provides more comprehensive key detection including special keys, modifier keys, and all printable characters.
// Deprecated approach
public void onEvent(KeyPressedEvent event) {
// Handle key press
}
// Recommended modern approach
public void onEvent(KeyDownEvent event) {
int keyCode = event.getKeyCode();
// Handle key down with full key support
}
- Since:
- 2007
- Version:
- 1.0
- Author:
- Marvin P. Warble Jr.
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionKeyPressedEvent(String keyCode, String charCode, String which) Deprecated.UseKeyDownEventconstructor instead -
Method Summary
Modifier and TypeMethodDescriptionvoiddispatchTo(KeyListener listener) Deprecated.Dispatches this event to the specified listener.Methods inherited from class com.oorian.messaging.events.client.KeyEvent
getCharCode, getKeyCode, getWhichMethods inherited from class com.oorian.messaging.events.client.ClientEvent
getSource, getTarget, setSource, setTarget
-
Constructor Details
-
KeyPressedEvent
Deprecated.UseKeyDownEventconstructor insteadConstructs a new KeyPressedEvent with the specified key information.Creates a key pressed event with key code, character code, and which key information from the browser's keyboard event.
- Parameters:
keyCode- the key code as a string (will be parsed to integer)charCode- the character code as a string (will be parsed to integer)which- the which key value as a string
-
-
Method Details
-
dispatchTo
Deprecated.Dispatches this event to the specified listener.This method implements the visitor pattern to deliver the event to the appropriate handler method on the KeyListener. It calls the listener's onEvent(KeyPressedEvent) method.
- Specified by:
dispatchToin classEvent<KeyListener>- Parameters:
listener- the KeyListener that will handle this event
-
KeyDownEventinstead. The browser keypress event is deprecated.