Package lib :: Module scripting :: Class Keyboard
[hide private]
[frames] | no frames]

Class Keyboard

source code

Provides access to the keyboard for event generation.

Instance Methods [hide private]
 
__init__(self, mediator) source code
 
send_keys(self, keyString)
Send a sequence of keys via keyboard events
source code
 
send_key(self, key, repeat=1)
Send a keyboard event
source code
 
press_key(self, key)
Send a key down event
source code
 
release_key(self, key)
Send a key up event
source code
 
fake_keypress(self, key, repeat=1)
Fake a keypress
source code
 
wait_for_keypress(self, key, modifiers=[], timeOut=10.0)
Wait for a keypress or key combination
source code
Method Details [hide private]

send_keys(self, keyString)

source code 

Send a sequence of keys via keyboard events

Usage: keyboard.send_keys(keyString)

Parameters:
  • keyString - string of keys (including special keys) to send

send_key(self, key, repeat=1)

source code 

Send a keyboard event

Usage: keyboard.send_key(key, repeat=1)

Parameters:
  • key - they key to be sent (e.g. "s" or "<enter>")
  • repeat - number of times to repeat the key event

press_key(self, key)

source code 

Send a key down event

Usage: keyboard.press_key(key)

The key will be treated as down until a matching release_key() is sent.

Parameters:
  • key - they key to be pressed (e.g. "s" or "<enter>")

release_key(self, key)

source code 

Send a key up event

Usage: keyboard.release_key(key)

If the specified key was not made down using press_key(), the event will be ignored.

Parameters:
  • key - they key to be released (e.g. "s" or "<enter>")

fake_keypress(self, key, repeat=1)

source code 

Fake a keypress

Usage: keyboard.fake_keypress(key, repeat=1)

Uses XTest to 'fake' a keypress. This is useful to send keypresses to some applications which won't respond to keyboard.send_key()

Parameters:
  • key - they key to be sent (e.g. "s" or "<enter>")
  • repeat - number of times to repeat the key event

wait_for_keypress(self, key, modifiers=[], timeOut=10.0)

source code 

Wait for a keypress or key combination

Usage: keyboard.wait_for_keypress(self, key, modifiers=[], timeOut=10.0)

Note: this function cannot be used to wait for modifier keys on their own

Parameters:
  • key - they key to wait for
  • modifiers - list of modifiers that should be pressed with the key
  • timeOut - maximum time, in seconds, to wait for the keypress to occur