Package org.sikuli.script
Class Key
- java.lang.Object
-
- org.sikuli.script.Key
-
public class Key extends 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 StringADDstatic StringALTstatic StringALTGRstatic StringBACKSPACEstatic charC_ADDstatic charC_ALTstatic charC_ALTGRstatic charC_CAPS_LOCKstatic charC_CMDstatic charC_CONTEXTstatic charC_CTRLstatic charC_DECIMALstatic charC_DELETEstatic charC_DIVIDEstatic charC_DOWNstatic charC_ENDstatic charC_ESCstatic charC_F1static charC_F10static charC_F11static charC_F12static charC_F13static charC_F14static charC_F15static charC_F2static charC_F3static charC_F4static charC_F5static charC_F6static charC_F7static charC_F8static charC_F9static charC_HOMEstatic charC_INSERTstatic charC_LEFTstatic charC_METAstatic charC_MINUSstatic charC_MULTIPLYstatic charC_NEXTstatic charC_NUM_LOCKstatic charC_NUM0static charC_NUM1static charC_NUM2static charC_NUM3static charC_NUM4static charC_NUM5static charC_NUM6static charC_NUM7static charC_NUM8static charC_NUM9static charC_PAGE_DOWNstatic charC_PAGE_UPstatic charC_PAUSEstatic charC_PRINTSCREENstatic charC_RIGHTstatic charC_SCROLL_LOCKstatic charC_SEPARATORstatic charC_SHIFTstatic charC_UPstatic charC_WINstatic StringCAPS_LOCKstatic charcMaxstatic StringCMDstatic charcMinstatic StringCONTEXTstatic StringCTRLstatic StringDECIMALstatic StringDELETEstatic StringDIVIDEstatic StringDOWNstatic StringENDstatic StringENTERstatic StringESCstatic StringF1static StringF10static StringF11static StringF12static StringF13static StringF14static StringF15static StringF2static StringF3static StringF4static StringF5static StringF6static StringF7static StringF8static StringF9static StringHOMEstatic StringINSERTstatic StringkeyboardUSstatic intkeyMaxLengthstatic StringLEFTstatic StringMETAstatic StringMINUSstatic StringMULTIPLYstatic StringNEXTstatic StringNUM_LOCKstatic StringNUM0static StringNUM1static StringNUM2static StringNUM3static StringNUM4static StringNUM5static StringNUM6static StringNUM7static StringNUM8static StringNUM9static StringPAGE_DOWNstatic StringPAGE_UPstatic StringPAUSEstatic StringPRINTSCREENstatic StringRIGHTstatic StringSCROLL_LOCKstatic StringSEPARATORstatic StringSHIFTstatic StringSPACEstatic StringTABstatic StringUPstatic StringWIN
-
Constructor Summary
Constructors Constructor Description Key()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static booleanaddHotkey(char key, int modifiers, HotkeyListener listener)add a hotkey and listenerstatic booleanaddHotkey(String key, int modifiers, HotkeyListener listener)add a hotkey and listenerstatic StringconvertKeyToText(int code, int mod)INTERNAL USE ONLYprotected static intconvertModifiers(String mod)static voidcreateKeyTable()INTERNAL USE ONLY create a table containing all relevant key, keycode and keytext settings for VK_xxxstatic voiddump()static intgetHotkeyModifier()HotKey modifier to be used with Sikuli's HotKey featurestatic StringgetTextFromKeycode(int key)static booleanisLockOn(char key)get the lock state of the given keystatic booleanisModifier(String token)static booleanisRepeatable(String token)static booleanremoveHotkey(char key, int modifiers)remove a hotkey and listenerstatic booleanremoveHotkey(String key, int modifiers)remove a hotkey and listenerstatic int[]toJavaKeyCode(char key)Convert Sikuli Key to Java virtual key codestatic int[]toJavaKeyCode(String key)Convert Sikuli Key to Java virtual key codestatic inttoJavaKeyCodeFromText(String key)static StringtoJavaKeyCodeText(char key)
-
-
-
Field Detail
-
keyboardUS
public static String keyboardUS
-
SPACE
public static final String SPACE
- See Also:
- Constant Field Values
-
ENTER
public static final String ENTER
- See Also:
- Constant Field Values
-
BACKSPACE
public static final String BACKSPACE
- See Also:
- Constant Field Values
-
TAB
public static final String TAB
- See Also:
- Constant Field Values
-
ESC
public static final String ESC
- See Also:
- Constant Field Values
-
C_ESC
public static final char C_ESC
- See Also:
- Constant Field Values
-
UP
public static final String UP
- See Also:
- Constant Field Values
-
C_UP
public static final char C_UP
- See Also:
- Constant Field Values
-
RIGHT
public static final String RIGHT
- See Also:
- Constant Field Values
-
C_RIGHT
public static final char C_RIGHT
- See Also:
- Constant Field Values
-
DOWN
public static final String DOWN
- See Also:
- Constant Field Values
-
C_DOWN
public static final char C_DOWN
- See Also:
- Constant Field Values
-
LEFT
public static final 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 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 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 String DELETE
- See Also:
- Constant Field Values
-
C_DELETE
public static final char C_DELETE
- See Also:
- Constant Field Values
-
END
public static final String END
- See Also:
- Constant Field Values
-
C_END
public static final char C_END
- See Also:
- Constant Field Values
-
HOME
public static final String HOME
- See Also:
- Constant Field Values
-
C_HOME
public static final char C_HOME
- See Also:
- Constant Field Values
-
INSERT
public static final String INSERT
- See Also:
- Constant Field Values
-
C_INSERT
public static final char C_INSERT
- See Also:
- Constant Field Values
-
F1
public static final String F1
- See Also:
- Constant Field Values
-
C_F1
public static final char C_F1
- See Also:
- Constant Field Values
-
F2
public static final String F2
- See Also:
- Constant Field Values
-
C_F2
public static final char C_F2
- See Also:
- Constant Field Values
-
F3
public static final String F3
- See Also:
- Constant Field Values
-
C_F3
public static final char C_F3
- See Also:
- Constant Field Values
-
F4
public static final String F4
- See Also:
- Constant Field Values
-
C_F4
public static final char C_F4
- See Also:
- Constant Field Values
-
F5
public static final String F5
- See Also:
- Constant Field Values
-
C_F5
public static final char C_F5
- See Also:
- Constant Field Values
-
F6
public static final String F6
- See Also:
- Constant Field Values
-
C_F6
public static final char C_F6
- See Also:
- Constant Field Values
-
F7
public static final String F7
- See Also:
- Constant Field Values
-
C_F7
public static final char C_F7
- See Also:
- Constant Field Values
-
F8
public static final String F8
- See Also:
- Constant Field Values
-
C_F8
public static final char C_F8
- See Also:
- Constant Field Values
-
F9
public static final String F9
- See Also:
- Constant Field Values
-
C_F9
public static final char C_F9
- See Also:
- Constant Field Values
-
F10
public static final String F10
- See Also:
- Constant Field Values
-
C_F10
public static final char C_F10
- See Also:
- Constant Field Values
-
F11
public static final String F11
- See Also:
- Constant Field Values
-
C_F11
public static final char C_F11
- See Also:
- Constant Field Values
-
F12
public static final String F12
- See Also:
- Constant Field Values
-
C_F12
public static final char C_F12
- See Also:
- Constant Field Values
-
F13
public static final String F13
- See Also:
- Constant Field Values
-
C_F13
public static final char C_F13
- See Also:
- Constant Field Values
-
F14
public static final String F14
- See Also:
- Constant Field Values
-
C_F14
public static final char C_F14
- See Also:
- Constant Field Values
-
F15
public static final String F15
- See Also:
- Constant Field Values
-
C_F15
public static final char C_F15
- See Also:
- Constant Field Values
-
SHIFT
public static final String SHIFT
- See Also:
- Constant Field Values
-
C_SHIFT
public static final char C_SHIFT
- See Also:
- Constant Field Values
-
CTRL
public static final String CTRL
- See Also:
- Constant Field Values
-
C_CTRL
public static final char C_CTRL
- See Also:
- Constant Field Values
-
ALT
public static final String ALT
- See Also:
- Constant Field Values
-
C_ALT
public static final char C_ALT
- See Also:
- Constant Field Values
-
ALTGR
public static final String ALTGR
- See Also:
- Constant Field Values
-
C_ALTGR
public static final char C_ALTGR
- See Also:
- Constant Field Values
-
META
public static final String META
- See Also:
- Constant Field Values
-
C_META
public static final char C_META
- See Also:
- Constant Field Values
-
CMD
public static final String CMD
- See Also:
- Constant Field Values
-
C_CMD
public static final char C_CMD
- See Also:
- Constant Field Values
-
WIN
public static final String WIN
- See Also:
- Constant Field Values
-
C_WIN
public static final char C_WIN
- See Also:
- Constant Field Values
-
PRINTSCREEN
public static final 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 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 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 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 String NUM0
- See Also:
- Constant Field Values
-
C_NUM0
public static final char C_NUM0
- See Also:
- Constant Field Values
-
NUM1
public static final String NUM1
- See Also:
- Constant Field Values
-
C_NUM1
public static final char C_NUM1
- See Also:
- Constant Field Values
-
NUM2
public static final String NUM2
- See Also:
- Constant Field Values
-
C_NUM2
public static final char C_NUM2
- See Also:
- Constant Field Values
-
NUM3
public static final String NUM3
- See Also:
- Constant Field Values
-
C_NUM3
public static final char C_NUM3
- See Also:
- Constant Field Values
-
NUM4
public static final String NUM4
- See Also:
- Constant Field Values
-
C_NUM4
public static final char C_NUM4
- See Also:
- Constant Field Values
-
NUM5
public static final String NUM5
- See Also:
- Constant Field Values
-
C_NUM5
public static final char C_NUM5
- See Also:
- Constant Field Values
-
NUM6
public static final String NUM6
- See Also:
- Constant Field Values
-
C_NUM6
public static final char C_NUM6
- See Also:
- Constant Field Values
-
NUM7
public static final String NUM7
- See Also:
- Constant Field Values
-
C_NUM7
public static final char C_NUM7
- See Also:
- Constant Field Values
-
NUM8
public static final String NUM8
- See Also:
- Constant Field Values
-
C_NUM8
public static final char C_NUM8
- See Also:
- Constant Field Values
-
NUM9
public static final String NUM9
- See Also:
- Constant Field Values
-
C_NUM9
public static final char C_NUM9
- See Also:
- Constant Field Values
-
SEPARATOR
public static final 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 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 String ADD
- See Also:
- Constant Field Values
-
C_ADD
public static final char C_ADD
- See Also:
- Constant Field Values
-
MINUS
public static final String MINUS
- See Also:
- Constant Field Values
-
C_MINUS
public static final char C_MINUS
- See Also:
- Constant Field Values
-
MULTIPLY
public static final String MULTIPLY
- See Also:
- Constant Field Values
-
C_MULTIPLY
public static final char C_MULTIPLY
- See Also:
- Constant Field Values
-
DIVIDE
public static final String DIVIDE
- See Also:
- Constant Field Values
-
C_DIVIDE
public static final char C_DIVIDE
- See Also:
- Constant Field Values
-
DECIMAL
public static final String DECIMAL
- See Also:
- Constant Field Values
-
C_DECIMAL
public static final char C_DECIMAL
- See Also:
- Constant Field Values
-
CONTEXT
public static final String CONTEXT
- See Also:
- Constant Field Values
-
C_CONTEXT
public static final char C_CONTEXT
- See Also:
- Constant Field Values
-
NEXT
public static final 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
-
-
Method Detail
-
addHotkey
public static boolean addHotkey(String key, int modifiers, 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, 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(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 String getTextFromKeycode(int key)
-
isRepeatable
public static boolean isRepeatable(String token)
-
isModifier
public static boolean isModifier(String token)
-
toJavaKeyCodeFromText
public static int toJavaKeyCodeFromText(String key)
-
dump
public static void dump()
-
toJavaKeyCode
public static int[] toJavaKeyCode(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 String toJavaKeyCodeText(char key)
- Parameters:
key- as Character- Returns:
- a printable version of a special key
-
convertModifiers
protected static int convertModifiers(String mod)
-
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 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
-
-