Enum Class Keys

java.lang.Object
java.lang.Enum<Keys>
org.openqa.selenium.Keys
All Implemented Interfaces:
Serializable, CharSequence, Comparable<Keys>, Constable

@NullMarked public enum Keys extends Enum<Keys> implements CharSequence
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:
  • Enum Constant Details

    • NULL

      public static final Keys NULL
    • CANCEL

      public static final Keys CANCEL
    • HELP

      public static final Keys HELP
    • BACK_SPACE

      public static final Keys BACK_SPACE
    • TAB

      public static final Keys TAB
    • CLEAR

      public static final Keys CLEAR
    • RETURN

      public static final Keys RETURN
    • ENTER

      public static final Keys ENTER
    • SHIFT

      public static final Keys SHIFT
    • LEFT_SHIFT

      public static final Keys LEFT_SHIFT
    • CONTROL

      public static final Keys CONTROL
    • LEFT_CONTROL

      public static final Keys LEFT_CONTROL
    • ALT

      public static final Keys ALT
    • LEFT_ALT

      public static final Keys LEFT_ALT
    • PAUSE

      public static final Keys PAUSE
    • ESCAPE

      public static final Keys ESCAPE
    • SPACE

      public static final Keys SPACE
    • PAGE_UP

      public static final Keys PAGE_UP
    • PAGE_DOWN

      public static final Keys PAGE_DOWN
    • END

      public static final Keys END
    • HOME

      public static final Keys HOME
    • LEFT

      public static final Keys LEFT
    • ARROW_LEFT

      public static final Keys ARROW_LEFT
    • UP

      public static final Keys UP
    • ARROW_UP

      public static final Keys ARROW_UP
    • ARROW_RIGHT

      public static final Keys ARROW_RIGHT
    • DOWN

      public static final Keys DOWN
    • ARROW_DOWN

      public static final Keys ARROW_DOWN
    • INSERT

      public static final Keys INSERT
    • DELETE

      public static final Keys DELETE
    • SEMICOLON

      public static final Keys SEMICOLON
    • EQUALS

      public static final Keys EQUALS
    • NUMPAD0

      public static final Keys NUMPAD0
    • NUMPAD1

      public static final Keys NUMPAD1
    • NUMPAD2

      public static final Keys NUMPAD2
    • NUMPAD3

      public static final Keys NUMPAD3
    • NUMPAD4

      public static final Keys NUMPAD4
    • NUMPAD5

      public static final Keys NUMPAD5
    • NUMPAD6

      public static final Keys NUMPAD6
    • NUMPAD7

      public static final Keys NUMPAD7
    • NUMPAD8

      public static final Keys NUMPAD8
    • NUMPAD9

      public static final Keys NUMPAD9
    • MULTIPLY

      public static final Keys MULTIPLY
    • ADD

      public static final Keys ADD
    • SEPARATOR

      public static final Keys SEPARATOR
    • SUBTRACT

      public static final Keys SUBTRACT
    • DECIMAL

      public static final Keys DECIMAL
    • DIVIDE

      public static final Keys DIVIDE
    • F1

      public static final Keys F1
    • F2

      public static final Keys F2
    • F3

      public static final Keys F3
    • F4

      public static final Keys F4
    • F5

      public static final Keys F5
    • F6

      public static final Keys F6
    • F7

      public static final Keys F7
    • F8

      public static final Keys F8
    • F9

      public static final Keys F9
    • F10

      public static final Keys F10
    • F11

      public static final Keys F11
    • F12

      public static final Keys F12
    • META

      public static final Keys META
    • COMMAND

      public static final Keys COMMAND
    • RIGHT_SHIFT

      public static final Keys RIGHT_SHIFT
    • RIGHT_CONTROL

      public static final Keys RIGHT_CONTROL
    • RIGHT_ALT

      public static final Keys RIGHT_ALT
    • RIGHT_COMMAND

      public static final Keys RIGHT_COMMAND
    • OPTION

      public static final Keys OPTION
    • FN

      public static final Keys FN
    • ZENKAKU_HANKAKU

      public static final Keys ZENKAKU_HANKAKU
  • Method Details

    • values

      public static Keys[] 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

      public static Keys valueOf(String name)
      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 name
      NullPointerException - if the argument is null
    • getCodePoint

      public int getCodePoint()
    • charAt

      public char charAt(int index)
      Specified by:
      charAt in interface CharSequence
    • length

      public int length()
      Specified by:
      length in interface CharSequence
    • subSequence

      public CharSequence subSequence(int start, int end)
      Specified by:
      subSequence in interface CharSequence
    • toString

      public String toString()
      Specified by:
      toString in interface CharSequence
      Overrides:
      toString in class Enum<Keys>
    • chord

      public static String chord(CharSequence... value)
      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

      public static String chord(Iterable<CharSequence> value)
      Overload of chord(CharSequence...) that accepts an iterable.
      Parameters:
      value - characters to send
      Returns:
      String representation of the char sequence
    • getKeyFromUnicode

      public static @Nullable Keys getKeyFromUnicode(char key)
      Retrieves the Keys 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