Package org.openqa.selenium
Enum Class Keys
- All Implemented Interfaces:
Serializable
,CharSequence
,Comparable<Keys>
,Constable
Representations of pressable keys that aren't text. These are stored in the Unicode PUA (Private
Use Area) code points, 0xE000–0xF8FF. These values are used internally by WebDriver to simulate
keyboard input where standard Unicode characters are insufficient, such as modifier and control
keys.
The codes follow conventions partially established by the W3C WebDriver specification and the Selenium project. Some values (e.g., RIGHT_SHIFT, RIGHT_COMMAND) are used in ChromeDriver but are not currently part of the W3C spec. Others (e.g., OPTION, FN) are symbolic and reserved for possible future mapping.
For consistency across platforms and drivers, values should be verified before assuming native support.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>>
-
Enum Constant Summary
Enum ConstantsEnum ConstantDescription -
Method Summary
Modifier and TypeMethodDescriptionchar
charAt
(int index) static String
chord
(CharSequence... value) Simulate pressing many keys at once in a "chord".static String
chord
(Iterable<CharSequence> value) Overload ofchord(CharSequence...)
that accepts an iterable.int
static @Nullable Keys
getKeyFromUnicode
(char key) Retrieves theKeys
enum constant corresponding to the given Unicode character.int
length()
subSequence
(int start, int end) toString()
static Keys
Returns the enum constant of this class with the specified name.static Keys[]
values()
Returns an array containing the constants of this enum class, in the order they are declared.Methods inherited from class java.lang.Enum
clone, compareTo, describeConstable, equals, finalize, getDeclaringClass, hashCode, name, ordinal, valueOf
Methods inherited from interface java.lang.CharSequence
chars, codePoints, isEmpty
-
Enum Constant Details
-
NULL
-
CANCEL
-
HELP
-
BACK_SPACE
-
TAB
-
CLEAR
-
RETURN
-
ENTER
-
SHIFT
-
LEFT_SHIFT
-
CONTROL
-
LEFT_CONTROL
-
ALT
-
LEFT_ALT
-
PAUSE
-
ESCAPE
-
SPACE
-
PAGE_UP
-
PAGE_DOWN
-
END
-
HOME
-
LEFT
-
ARROW_LEFT
-
UP
-
ARROW_UP
-
RIGHT
-
ARROW_RIGHT
-
DOWN
-
ARROW_DOWN
-
INSERT
-
DELETE
-
SEMICOLON
-
EQUALS
-
NUMPAD0
-
NUMPAD1
-
NUMPAD2
-
NUMPAD3
-
NUMPAD4
-
NUMPAD5
-
NUMPAD6
-
NUMPAD7
-
NUMPAD8
-
NUMPAD9
-
MULTIPLY
-
ADD
-
SEPARATOR
-
SUBTRACT
-
DECIMAL
-
DIVIDE
-
F1
-
F2
-
F3
-
F4
-
F5
-
F6
-
F7
-
F8
-
F9
-
F10
-
F11
-
F12
-
META
-
COMMAND
-
RIGHT_SHIFT
-
RIGHT_CONTROL
-
RIGHT_ALT
-
RIGHT_COMMAND
-
OPTION
-
FN
-
ZENKAKU_HANKAKU
-
-
Method Details
-
values
Returns an array containing the constants of this enum class, in the order they are declared.- Returns:
- an array containing the constants of this enum class, in the order they are declared
-
valueOf
Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)- Parameters:
name
- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException
- if this enum class has no constant with the specified nameNullPointerException
- if the argument is null
-
getCodePoint
public int getCodePoint() -
charAt
public char charAt(int index) - Specified by:
charAt
in interfaceCharSequence
-
length
public int length()- Specified by:
length
in interfaceCharSequence
-
subSequence
- Specified by:
subSequence
in interfaceCharSequence
-
toString
- Specified by:
toString
in interfaceCharSequence
- Overrides:
toString
in classEnum<Keys>
-
chord
Simulate pressing many keys at once in a "chord". Takes a sequence of Keys.XXXX or strings; appends each to a string, adds the chord termination key (Keys.NULL), and returns it.Note: Keys.NULL signals release of modifier keys like CTRL/ALT/SHIFT via keyup events.
- Parameters:
value
- characters to send- Returns:
- String representation of the char sequence
-
chord
Overload ofchord(CharSequence...)
that accepts an iterable.- Parameters:
value
- characters to send- Returns:
- String representation of the char sequence
-
getKeyFromUnicode
Retrieves theKeys
enum constant corresponding to the given Unicode character.- Parameters:
key
- unicode character code- Returns:
- special key linked to the character code, or null if not found
-