Package com.jbstrap.core.event
Class KeyboardEvent
java.lang.Object
com.jbstrap.core.event.BaseEvent
com.jbstrap.core.event.BrowserEvent
com.jbstrap.core.event.KeyboardEvent
This class contains the data about the keyboard events.
These are the following:
- The client on which the event occurred
- The ID of the component on which the event occurred
- The event type
- The instance of the component, on which the event occurred
- The event's unique ID
- If the event is trusted
- The amount of mouse clicks
- The event phase
- If the event is bubbleable
- If the event can prevent the default operation
- Marks if the event had defaultPrevented() called
- If the event is composed or not
- The ID of the client, on which the event occurred
- If the ALT button was held down during the event
- If the CONTROL button was held down during the event
- If the Meta button was held down during the event
- If the SHIFT button was held down during the event
- The details of the pressed button (charCode, keyCode and the corresponding character)
- The location (on the keyboard) of the pressed button
- Since:
- 4.0
- Author:
- JBStrap
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionDetermines if the ALT key was held down when the event occurredGets the pressed key character's UnicodegetCode()
Gets the pressed key's code in a String formatDetermines if the CONTROL key was held down when the event occurredgetKey()
Gets the pressed key's nameGets the pressed key's UnicodeGets the pressed key's locationDetermines if the Meta key was held down when the event occurredDetermines if the SHIFT key was held down when the event occurredgetWhich()
Gets the Unicode character code of the keyMethods inherited from class com.jbstrap.core.event.BrowserEvent
fireEvent, getBubbles, getCancelable, getClientId, getComposed, getDefaultPrevented, getDetail, getEventPhase, getIsTrusted, getType
Methods inherited from class com.jbstrap.core.event.BaseEvent
getClient, getComponent, getEventId, getEventType, getSenderId
-
Constructor Details
-
KeyboardEvent
public KeyboardEvent()
-
-
Method Details
-
getAltKey
Determines if the ALT key was held down when the event occurred- Returns:
true
, if the ALT button was held down when the event occurred, otherwisefalse
-
getCharCode
Gets the pressed key character's Unicode- Returns:
- The pressed key character's Unicode
-
getCode
Gets the pressed key's code in a String format- Returns:
- The pressed key's code in a String format (ex: "a", "enter" or "f1")
-
getCtrlKey
Determines if the CONTROL key was held down when the event occurred- Returns:
true
, if the CONTROL button was held down when the event occurred, otherwisefalse
-
getKey
Gets the pressed key's name- Returns:
The key name
Possible values:- One character (like "a", "W", "4", "+" or "$")
- Multiple characters (like "F1", "Enter", "HOME" or "CAPS LOCK")
-
getKeyCode
Gets the pressed key's Unicode- Returns:
- The pressed key's Unicode
-
getLocation
Gets the pressed key's location- Returns:
- A number corresponding to the pressed key's location.
Possible values:
- 0. DOM_KEY_LOCATION_STANDARD : Keys that only appear on the keyboard once
- 1. DOM_KEY_LOCATION_LEFT : Keys that appear on the left side
- 2. DOM_KEY_LOCATION_RIGHT : Keys that appear on the right side
- 3. DOM_KEY_LOCATION_NUMPAD :Keys that appear on the numpad
-
getMetaKey
Determines if the Meta key was held down when the event occurred- Returns:
true
, if the Meta button was held down when the event occurred, otherwisefalse
-
getShiftKey
Determines if the SHIFT key was held down when the event occurred- Returns:
true
, if the SHIFT button was held down when the event occurred, otherwisefalse
-
getWhich
Gets the Unicode character code of the key- Returns:
- The Unicode character code of the key
-