Package org.sikuli.script
Class Key
- java.lang.Object
-
- org.sikuli.script.Key
-
public class Key extends java.lang.Object
this class implements an interface to the Java key system as represented by java.awt.event.KeyEvent. for the functions Region.type() and Region.write() by translating key constants for special keys and plain text per character.
for details consult the docs
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
ADD
static java.lang.String
ALT
static java.lang.String
ALTGR
static java.lang.String
BACKSPACE
static char
C_ADD
static char
C_ALT
static char
C_ALTGR
static char
C_CAPS_LOCK
static char
C_CMD
static char
C_CONTEXT
static char
C_CTRL
static char
C_DECIMAL
static char
C_DELETE
static char
C_DIVIDE
static char
C_DOWN
static char
C_END
static char
C_ESC
static char
C_F1
static char
C_F10
static char
C_F11
static char
C_F12
static char
C_F13
static char
C_F14
static char
C_F15
static char
C_F2
static char
C_F3
static char
C_F4
static char
C_F5
static char
C_F6
static char
C_F7
static char
C_F8
static char
C_F9
static char
C_HOME
static char
C_INSERT
static char
C_LEFT
static char
C_META
static char
C_MINUS
static char
C_MULTIPLY
static char
C_NEXT
static char
C_NUM_LOCK
static char
C_NUM0
static char
C_NUM1
static char
C_NUM2
static char
C_NUM3
static char
C_NUM4
static char
C_NUM5
static char
C_NUM6
static char
C_NUM7
static char
C_NUM8
static char
C_NUM9
static char
C_PAGE_DOWN
static char
C_PAGE_UP
static char
C_PAUSE
static char
C_PRINTSCREEN
static char
C_RIGHT
static char
C_SCROLL_LOCK
static char
C_SEPARATOR
static char
C_SHIFT
static char
C_UP
static char
C_WIN
static java.lang.String
CAPS_LOCK
static char
cMax
static java.lang.String
CMD
static char
cMin
static java.lang.String
CONTEXT
static java.lang.String
CTRL
static java.lang.String
DECIMAL
static java.lang.String
DELETE
static java.lang.String
DIVIDE
static java.lang.String
DOWN
static java.lang.String
END
static java.lang.String
ENTER
static java.lang.String
ESC
static java.lang.String
F1
static java.lang.String
F10
static java.lang.String
F11
static java.lang.String
F12
static java.lang.String
F13
static java.lang.String
F14
static java.lang.String
F15
static java.lang.String
F2
static java.lang.String
F3
static java.lang.String
F4
static java.lang.String
F5
static java.lang.String
F6
static java.lang.String
F7
static java.lang.String
F8
static java.lang.String
F9
static java.lang.String
HOME
static java.lang.String
INSERT
static java.lang.String
keyboardUS
static int
keyMaxLength
static java.lang.String
LEFT
static java.lang.String
META
static java.lang.String
MINUS
static char[]
MODIFIER_KEYS
static java.lang.String
MULTIPLY
static java.lang.String
NEXT
static java.lang.String
NUM_LOCK
static java.lang.String
NUM0
static java.lang.String
NUM1
static java.lang.String
NUM2
static java.lang.String
NUM3
static java.lang.String
NUM4
static java.lang.String
NUM5
static java.lang.String
NUM6
static java.lang.String
NUM7
static java.lang.String
NUM8
static java.lang.String
NUM9
static java.lang.String
PAGE_DOWN
static java.lang.String
PAGE_UP
static java.lang.String
PAUSE
static java.lang.String
PRINTSCREEN
static java.lang.String
RIGHT
static java.lang.String
SCROLL_LOCK
static java.lang.String
SEPARATOR
static java.lang.String
SHIFT
static java.lang.String
SPACE
static java.lang.String
TAB
static java.lang.String
UP
static java.lang.String
WIN
-
Constructor Summary
Constructors Constructor Description Key()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static boolean
addHotkey(char key, int modifiers, org.sikuli.basics.HotkeyListener listener)
add a hotkey and listenerstatic boolean
addHotkey(java.lang.String key, int modifiers, org.sikuli.basics.HotkeyListener listener)
add a hotkey and listenerstatic java.lang.String
convertKeyToText(int code, int mod)
INTERNAL USE ONLYstatic void
createKeyTable()
INTERNAL USE ONLY create a table containing all relevant key, keycode and keytext settings for VK_xxxstatic void
dump()
static int
getHotkeyModifier()
HotKey modifier to be used with Sikuli's HotKey featurestatic java.lang.String
getTextFromKeycode(int key)
static boolean
isLockOn(char key)
get the lock state of the given keystatic boolean
isModifier(char ch)
static boolean
isModifier(java.lang.String token)
static boolean
isRepeatable(java.lang.String token)
static boolean
removeHotkey(char key, int modifiers)
remove a hotkey and listenerstatic boolean
removeHotkey(java.lang.String key, int modifiers)
remove a hotkey and listenerstatic int[]
toJavaKeyCode(char key)
Convert Sikuli Key to Java virtual key codestatic int[]
toJavaKeyCode(java.lang.String key)
Convert Sikuli Key to Java virtual key codestatic int
toJavaKeyCodeFromText(java.lang.String key)
static java.lang.String
toJavaKeyCodeText(char key)
-
-
-
Field Detail
-
keyboardUS
public static java.lang.String keyboardUS
-
SPACE
public static final java.lang.String SPACE
- See Also:
- Constant Field Values
-
ENTER
public static final java.lang.String ENTER
- See Also:
- Constant Field Values
-
BACKSPACE
public static final java.lang.String BACKSPACE
- See Also:
- Constant Field Values
-
TAB
public static final java.lang.String TAB
- See Also:
- Constant Field Values
-
ESC
public static final java.lang.String ESC
- See Also:
- Constant Field Values
-
C_ESC
public static final char C_ESC
- See Also:
- Constant Field Values
-
UP
public static final java.lang.String UP
- See Also:
- Constant Field Values
-
C_UP
public static final char C_UP
- See Also:
- Constant Field Values
-
RIGHT
public static final java.lang.String RIGHT
- See Also:
- Constant Field Values
-
C_RIGHT
public static final char C_RIGHT
- See Also:
- Constant Field Values
-
DOWN
public static final java.lang.String DOWN
- See Also:
- Constant Field Values
-
C_DOWN
public static final char C_DOWN
- See Also:
- Constant Field Values
-
LEFT
public static final java.lang.String LEFT
- See Also:
- Constant Field Values
-
C_LEFT
public static final char C_LEFT
- See Also:
- Constant Field Values
-
PAGE_UP
public static final java.lang.String PAGE_UP
- See Also:
- Constant Field Values
-
C_PAGE_UP
public static final char C_PAGE_UP
- See Also:
- Constant Field Values
-
PAGE_DOWN
public static final java.lang.String PAGE_DOWN
- See Also:
- Constant Field Values
-
C_PAGE_DOWN
public static final char C_PAGE_DOWN
- See Also:
- Constant Field Values
-
DELETE
public static final java.lang.String DELETE
- See Also:
- Constant Field Values
-
C_DELETE
public static final char C_DELETE
- See Also:
- Constant Field Values
-
END
public static final java.lang.String END
- See Also:
- Constant Field Values
-
C_END
public static final char C_END
- See Also:
- Constant Field Values
-
HOME
public static final java.lang.String HOME
- See Also:
- Constant Field Values
-
C_HOME
public static final char C_HOME
- See Also:
- Constant Field Values
-
INSERT
public static final java.lang.String INSERT
- See Also:
- Constant Field Values
-
C_INSERT
public static final char C_INSERT
- See Also:
- Constant Field Values
-
F1
public static final java.lang.String F1
- See Also:
- Constant Field Values
-
C_F1
public static final char C_F1
- See Also:
- Constant Field Values
-
F2
public static final java.lang.String F2
- See Also:
- Constant Field Values
-
C_F2
public static final char C_F2
- See Also:
- Constant Field Values
-
F3
public static final java.lang.String F3
- See Also:
- Constant Field Values
-
C_F3
public static final char C_F3
- See Also:
- Constant Field Values
-
F4
public static final java.lang.String F4
- See Also:
- Constant Field Values
-
C_F4
public static final char C_F4
- See Also:
- Constant Field Values
-
F5
public static final java.lang.String F5
- See Also:
- Constant Field Values
-
C_F5
public static final char C_F5
- See Also:
- Constant Field Values
-
F6
public static final java.lang.String F6
- See Also:
- Constant Field Values
-
C_F6
public static final char C_F6
- See Also:
- Constant Field Values
-
F7
public static final java.lang.String F7
- See Also:
- Constant Field Values
-
C_F7
public static final char C_F7
- See Also:
- Constant Field Values
-
F8
public static final java.lang.String F8
- See Also:
- Constant Field Values
-
C_F8
public static final char C_F8
- See Also:
- Constant Field Values
-
F9
public static final java.lang.String F9
- See Also:
- Constant Field Values
-
C_F9
public static final char C_F9
- See Also:
- Constant Field Values
-
F10
public static final java.lang.String F10
- See Also:
- Constant Field Values
-
C_F10
public static final char C_F10
- See Also:
- Constant Field Values
-
F11
public static final java.lang.String F11
- See Also:
- Constant Field Values
-
C_F11
public static final char C_F11
- See Also:
- Constant Field Values
-
F12
public static final java.lang.String F12
- See Also:
- Constant Field Values
-
C_F12
public static final char C_F12
- See Also:
- Constant Field Values
-
F13
public static final java.lang.String F13
- See Also:
- Constant Field Values
-
C_F13
public static final char C_F13
- See Also:
- Constant Field Values
-
F14
public static final java.lang.String F14
- See Also:
- Constant Field Values
-
C_F14
public static final char C_F14
- See Also:
- Constant Field Values
-
F15
public static final java.lang.String F15
- See Also:
- Constant Field Values
-
C_F15
public static final char C_F15
- See Also:
- Constant Field Values
-
SHIFT
public static final java.lang.String SHIFT
- See Also:
- Constant Field Values
-
C_SHIFT
public static final char C_SHIFT
- See Also:
- Constant Field Values
-
CTRL
public static final java.lang.String CTRL
- See Also:
- Constant Field Values
-
C_CTRL
public static final char C_CTRL
- See Also:
- Constant Field Values
-
ALT
public static final java.lang.String ALT
- See Also:
- Constant Field Values
-
C_ALT
public static final char C_ALT
- See Also:
- Constant Field Values
-
ALTGR
public static final java.lang.String ALTGR
- See Also:
- Constant Field Values
-
C_ALTGR
public static final char C_ALTGR
- See Also:
- Constant Field Values
-
META
public static final java.lang.String META
- See Also:
- Constant Field Values
-
C_META
public static final char C_META
- See Also:
- Constant Field Values
-
CMD
public static final java.lang.String CMD
- See Also:
- Constant Field Values
-
C_CMD
public static final char C_CMD
- See Also:
- Constant Field Values
-
WIN
public static final java.lang.String WIN
- See Also:
- Constant Field Values
-
C_WIN
public static final char C_WIN
- See Also:
- Constant Field Values
-
PRINTSCREEN
public static final java.lang.String PRINTSCREEN
- See Also:
- Constant Field Values
-
C_PRINTSCREEN
public static final char C_PRINTSCREEN
- See Also:
- Constant Field Values
-
SCROLL_LOCK
public static final java.lang.String SCROLL_LOCK
- See Also:
- Constant Field Values
-
C_SCROLL_LOCK
public static final char C_SCROLL_LOCK
- See Also:
- Constant Field Values
-
PAUSE
public static final java.lang.String PAUSE
- See Also:
- Constant Field Values
-
C_PAUSE
public static final char C_PAUSE
- See Also:
- Constant Field Values
-
CAPS_LOCK
public static final java.lang.String CAPS_LOCK
- See Also:
- Constant Field Values
-
C_CAPS_LOCK
public static final char C_CAPS_LOCK
- See Also:
- Constant Field Values
-
NUM0
public static final java.lang.String NUM0
- See Also:
- Constant Field Values
-
C_NUM0
public static final char C_NUM0
- See Also:
- Constant Field Values
-
NUM1
public static final java.lang.String NUM1
- See Also:
- Constant Field Values
-
C_NUM1
public static final char C_NUM1
- See Also:
- Constant Field Values
-
NUM2
public static final java.lang.String NUM2
- See Also:
- Constant Field Values
-
C_NUM2
public static final char C_NUM2
- See Also:
- Constant Field Values
-
NUM3
public static final java.lang.String NUM3
- See Also:
- Constant Field Values
-
C_NUM3
public static final char C_NUM3
- See Also:
- Constant Field Values
-
NUM4
public static final java.lang.String NUM4
- See Also:
- Constant Field Values
-
C_NUM4
public static final char C_NUM4
- See Also:
- Constant Field Values
-
NUM5
public static final java.lang.String NUM5
- See Also:
- Constant Field Values
-
C_NUM5
public static final char C_NUM5
- See Also:
- Constant Field Values
-
NUM6
public static final java.lang.String NUM6
- See Also:
- Constant Field Values
-
C_NUM6
public static final char C_NUM6
- See Also:
- Constant Field Values
-
NUM7
public static final java.lang.String NUM7
- See Also:
- Constant Field Values
-
C_NUM7
public static final char C_NUM7
- See Also:
- Constant Field Values
-
NUM8
public static final java.lang.String NUM8
- See Also:
- Constant Field Values
-
C_NUM8
public static final char C_NUM8
- See Also:
- Constant Field Values
-
NUM9
public static final java.lang.String NUM9
- See Also:
- Constant Field Values
-
C_NUM9
public static final char C_NUM9
- See Also:
- Constant Field Values
-
SEPARATOR
public static final java.lang.String SEPARATOR
- See Also:
- Constant Field Values
-
C_SEPARATOR
public static final char C_SEPARATOR
- See Also:
- Constant Field Values
-
NUM_LOCK
public static final java.lang.String NUM_LOCK
- See Also:
- Constant Field Values
-
C_NUM_LOCK
public static final char C_NUM_LOCK
- See Also:
- Constant Field Values
-
ADD
public static final java.lang.String ADD
- See Also:
- Constant Field Values
-
C_ADD
public static final char C_ADD
- See Also:
- Constant Field Values
-
MINUS
public static final java.lang.String MINUS
- See Also:
- Constant Field Values
-
C_MINUS
public static final char C_MINUS
- See Also:
- Constant Field Values
-
MULTIPLY
public static final java.lang.String MULTIPLY
- See Also:
- Constant Field Values
-
C_MULTIPLY
public static final char C_MULTIPLY
- See Also:
- Constant Field Values
-
DIVIDE
public static final java.lang.String DIVIDE
- See Also:
- Constant Field Values
-
C_DIVIDE
public static final char C_DIVIDE
- See Also:
- Constant Field Values
-
DECIMAL
public static final java.lang.String DECIMAL
- See Also:
- Constant Field Values
-
C_DECIMAL
public static final char C_DECIMAL
- See Also:
- Constant Field Values
-
CONTEXT
public static final java.lang.String CONTEXT
- See Also:
- Constant Field Values
-
C_CONTEXT
public static final char C_CONTEXT
- See Also:
- Constant Field Values
-
NEXT
public static final java.lang.String NEXT
- See Also:
- Constant Field Values
-
C_NEXT
public static final char C_NEXT
- See Also:
- Constant Field Values
-
cMax
public static final char cMax
- See Also:
- Constant Field Values
-
cMin
public static final char cMin
- See Also:
- Constant Field Values
-
keyMaxLength
public static int keyMaxLength
-
MODIFIER_KEYS
public static final char[] MODIFIER_KEYS
-
-
Method Detail
-
addHotkey
public static boolean addHotkey(java.lang.String key, int modifiers, org.sikuli.basics.HotkeyListener listener)
add a hotkey and listener- Parameters:
key
- respective key specifier according class Keymodifiers
- respective key specifier according class KeyModifierslistener
- a HotKeyListener instance- Returns:
- true if ok, false otherwise
-
addHotkey
public static boolean addHotkey(char key, int modifiers, org.sikuli.basics.HotkeyListener listener)
add a hotkey and listener- Parameters:
key
- respective key specifier according class Keymodifiers
- respective key specifier according class KeyModifierslistener
- a HotKeyListener instance- Returns:
- true if ok, false otherwise
-
removeHotkey
public static boolean removeHotkey(java.lang.String key, int modifiers)
remove a hotkey and listener- Parameters:
key
- respective key specifier according class Keymodifiers
- respective key specifier according class KeyModifiers- Returns:
- true if ok, false otherwise
-
removeHotkey
public static boolean removeHotkey(char key, int modifiers)
remove a hotkey and listener- Parameters:
key
- respective key specifier according class Keymodifiers
- respective key specifier according class KeyModifiers- Returns:
- true if ok, false otherwise
-
getTextFromKeycode
public static java.lang.String getTextFromKeycode(int key)
-
isRepeatable
public static boolean isRepeatable(java.lang.String token)
-
isModifier
public static boolean isModifier(java.lang.String token)
-
isModifier
public static boolean isModifier(char ch)
-
toJavaKeyCodeFromText
public static int toJavaKeyCodeFromText(java.lang.String key)
-
dump
public static void dump()
-
toJavaKeyCode
public static int[] toJavaKeyCode(java.lang.String key)
Convert Sikuli Key to Java virtual key code- Parameters:
key
- as String- Returns:
- the Java KeyCodes
-
toJavaKeyCode
public static int[] toJavaKeyCode(char key)
Convert Sikuli Key to Java virtual key code- Parameters:
key
- as Character- Returns:
- the Java KeyCodes
-
toJavaKeyCodeText
public static java.lang.String toJavaKeyCodeText(char key)
- Parameters:
key
- as Character- Returns:
- a printable version of a special key
-
isLockOn
public static boolean isLockOn(char key)
get the lock state of the given key- Parameters:
key
- as Character (scroll, caps, num)- Returns:
- true/false
-
getHotkeyModifier
public static int getHotkeyModifier()
HotKey modifier to be used with Sikuli's HotKey feature- Returns:
- META(CMD) on Mac, CTRL otherwise
-
convertKeyToText
public static java.lang.String convertKeyToText(int code, int mod)
INTERNAL USE ONLY- Parameters:
code
- keycodemod
- modifier- Returns:
- readable key text
-
createKeyTable
public static void createKeyTable()
INTERNAL USE ONLY create a table containing all relevant key, keycode and keytext settings for VK_xxx
-
-