Package org.sikuli.script
Class Key
- java.lang.Object
-
- org.sikuli.script.Key
-
public class Key extends java.lang.Objectthis 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.StringADDstatic java.lang.StringALTstatic java.lang.StringALTGRstatic java.lang.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 java.lang.StringCAPS_LOCKstatic charcMaxstatic java.lang.StringCMDstatic charcMinstatic java.lang.StringCONTEXTstatic java.lang.StringCTRLstatic java.lang.StringDECIMALstatic java.lang.StringDELETEstatic java.lang.StringDIVIDEstatic java.lang.StringDOWNstatic java.lang.StringENDstatic java.lang.StringENTERstatic java.lang.StringESCstatic java.lang.StringF1static java.lang.StringF10static java.lang.StringF11static java.lang.StringF12static java.lang.StringF13static java.lang.StringF14static java.lang.StringF15static java.lang.StringF2static java.lang.StringF3static java.lang.StringF4static java.lang.StringF5static java.lang.StringF6static java.lang.StringF7static java.lang.StringF8static java.lang.StringF9static java.lang.StringHOMEstatic java.lang.StringINSERTstatic java.lang.StringkeyboardUSstatic intkeyMaxLengthstatic java.lang.StringLEFTstatic java.lang.StringMETAstatic java.lang.StringMINUSstatic char[]MODIFIER_KEYSstatic java.lang.StringMULTIPLYstatic java.lang.StringNEXTstatic java.lang.StringNUM_LOCKstatic java.lang.StringNUM0static java.lang.StringNUM1static java.lang.StringNUM2static java.lang.StringNUM3static java.lang.StringNUM4static java.lang.StringNUM5static java.lang.StringNUM6static java.lang.StringNUM7static java.lang.StringNUM8static java.lang.StringNUM9static java.lang.StringPAGE_DOWNstatic java.lang.StringPAGE_UPstatic java.lang.StringPAUSEstatic java.lang.StringPRINTSCREENstatic java.lang.StringRIGHTstatic java.lang.StringSCROLL_LOCKstatic java.lang.StringSEPARATORstatic java.lang.StringSHIFTstatic java.lang.StringSPACEstatic java.lang.StringTABstatic java.lang.StringUPstatic java.lang.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, org.sikuli.basics.HotkeyListener listener)add a hotkey and listenerstatic booleanaddHotkey(java.lang.String key, int modifiers, org.sikuli.basics.HotkeyListener listener)add a hotkey and listenerstatic java.lang.StringconvertKeyToText(int code, int mod)INTERNAL USE ONLYstatic 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 java.lang.StringgetTextFromKeycode(int key)static booleanisLockOn(char key)get the lock state of the given keystatic booleanisModifier(char ch)static booleanisModifier(java.lang.String token)static booleanisRepeatable(java.lang.String token)static booleanremoveHotkey(char key, int modifiers)remove a hotkey and listenerstatic booleanremoveHotkey(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 inttoJavaKeyCodeFromText(java.lang.String key)static java.lang.StringtoJavaKeyCodeText(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
-
-