Class VirtualKey
-
- All Implemented Interfaces:
public final class VirtualKeyA virtual key represents a physical key on the keyboard. It's not the character generated by pressing the key.
Since the input device isn't a physical keyboard, but is instead a virtual keyboard, the virtual key will be set by the browser to match as closely as possible to what would happen with a physical keyboard, to maximize compatibility between physical and virtual input devices.
-
-
Constructor Summary
Constructors Constructor Description VirtualKey(String key, Integer keyCodeWithoutLocation, String code, Integer location, Integer keyCode, String text, VirtualKey shifted)
-
Method Summary
Modifier and Type Method Description final BooleanisModifier()final StringgetKey()The VirtualKey.key of the key pressed by the user, taking into consideration the state of modifier keys such as Shift as well as the keyboard locale and layout. final UnitsetKey(String key)The VirtualKey.key of the key pressed by the user, taking into consideration the state of modifier keys such as Shift as well as the keyboard locale and layout. final IntegergetKeyCodeWithoutLocation()Represents a system and implementation dependent numerical code identifying the unmodified value of the pressed key. final UnitsetKeyCodeWithoutLocation(Integer keyCodeWithoutLocation)Represents a system and implementation dependent numerical code identifying the unmodified value of the pressed key. final StringgetCode()The VirtualKey.code property represents a physical key on the keyboard (as opposed to the character generated by pressing the key). final UnitsetCode(String code)The VirtualKey.code property represents a physical key on the keyboard (as opposed to the character generated by pressing the key). final IntegergetLocation()The VirtualKey.location read-only property returns an unsigned long representing the location of the key on the keyboard or other input device. final UnitsetLocation(Integer location)The VirtualKey.location read-only property returns an unsigned long representing the location of the key on the keyboard or other input device. final IntegergetKeyCode()The deprecated VirtualKey.keyCode property represents a system and implementation dependent numerical code identifying the unmodified value of the pressed key. final UnitsetKeyCode(Integer keyCode)The deprecated VirtualKey.keyCode property represents a system and implementation dependent numerical code identifying the unmodified value of the pressed key. final StringgetText()Returns the value of the key pressed by the user. final UnitsetText(String text)Returns the value of the key pressed by the user. final VirtualKeygetShifted()The shifted key definition. final UnitsetShifted(VirtualKey shifted)The shifted key definition. -
-
Method Detail
-
isModifier
final Boolean isModifier()
-
getKey
final String getKey()
The VirtualKey.key of the key pressed by the user, taking into consideration the state of modifier keys such as Shift as well as the keyboard locale and layout.
Examples: "a", "b", "A", "B", "1", "2", "3", "Shift", "Enter", ...
-
setKey
final Unit setKey(String key)
The VirtualKey.key of the key pressed by the user, taking into consideration the state of modifier keys such as Shift as well as the keyboard locale and layout.
Examples: "a", "b", "A", "B", "1", "2", "3", "Shift", "Enter", ...
-
getKeyCodeWithoutLocation
final Integer getKeyCodeWithoutLocation()
Represents a system and implementation dependent numerical code identifying the unmodified value of the pressed key.
Note: The key code is a numeric value that represents a physical key on the keyboard. It's not the character.
Key code examples: 13, 65, 51, ...
You should avoid using this if possible; it's been deprecated for some time. Instead, you should use code if available. Codes are more reliable than key codes, because they are not affected by layout. Code example: "KeyA", "Digit3", "Enter", ...
-
setKeyCodeWithoutLocation
final Unit setKeyCodeWithoutLocation(Integer keyCodeWithoutLocation)
Represents a system and implementation dependent numerical code identifying the unmodified value of the pressed key.
Note: The key code is a numeric value that represents a physical key on the keyboard. It's not the character.
Key code examples: 13, 65, 51, ...
You should avoid using this if possible; it's been deprecated for some time. Instead, you should use code if available. Codes are more reliable than key codes, because they are not affected by layout. Code example: "KeyA", "Digit3", "Enter", ...
-
getCode
final String getCode()
The VirtualKey.code property represents a physical key on the keyboard (as opposed to the character generated by pressing the key). In other words, this property returns a value that isn't altered by keyboard layout or the state of the modifier keys.
If the input device isn't a physical keyboard, but is instead a virtual keyboard or accessibility device, the returned value will be set by the browser to match as closely as possible to what would happen with a physical keyboard, to maximize compatibility between physical and virtual input devices.
For example, the code returned is "KeyQ" for the Q key on a QWERTY layout keyboard. Code example: "KeyA", "Digit3", "Enter", ...
-
setCode
final Unit setCode(String code)
The VirtualKey.code property represents a physical key on the keyboard (as opposed to the character generated by pressing the key). In other words, this property returns a value that isn't altered by keyboard layout or the state of the modifier keys.
If the input device isn't a physical keyboard, but is instead a virtual keyboard or accessibility device, the returned value will be set by the browser to match as closely as possible to what would happen with a physical keyboard, to maximize compatibility between physical and virtual input devices.
For example, the code returned is "KeyQ" for the Q key on a QWERTY layout keyboard. Code example: "KeyA", "Digit3", "Enter", ...
-
getLocation
final Integer getLocation()
The VirtualKey.location read-only property returns an unsigned long representing the location of the key on the keyboard or other input device.
-
setLocation
final Unit setLocation(Integer location)
The VirtualKey.location read-only property returns an unsigned long representing the location of the key on the keyboard or other input device.
-
getKeyCode
final Integer getKeyCode()
The deprecated VirtualKey.keyCode property represents a system and implementation dependent numerical code identifying the unmodified value of the pressed key.
Note: The key code is a numeric value that represents a physical key on the keyboard. It's not the character.
Key code examples: 13, 65, 51, ...
You should avoid using this if possible; it's been deprecated for some time. Instead, you should use code if available. Codes are more reliable than key codes, because they are not affected by layout.
-
setKeyCode
final Unit setKeyCode(Integer keyCode)
The deprecated VirtualKey.keyCode property represents a system and implementation dependent numerical code identifying the unmodified value of the pressed key.
Note: The key code is a numeric value that represents a physical key on the keyboard. It's not the character.
Key code examples: 13, 65, 51, ...
You should avoid using this if possible; it's been deprecated for some time. Instead, you should use code if available. Codes are more reliable than key codes, because they are not affected by layout.
-
getText
final String getText()
Returns the value of the key pressed by the user. If the key is a printable character, this property returns the character.
-
setText
final Unit setText(String text)
Returns the value of the key pressed by the user. If the key is a printable character, this property returns the character.
-
getShifted
final VirtualKey getShifted()
The shifted key definition.
-
setShifted
final Unit setShifted(VirtualKey shifted)
The shifted key definition.
-
-
-
-