expyriment.io.Keyboard

class expyriment.io.Keyboard(default_keys=None)

A class implementing a keyboard input.

Calling expyriment.control.intialize(exp) will automatically create a keyboard instance and will reference it in exp.keyboard for easy access.

Methods

__init__(default_keys=None)

Create a keyboard input.

Parameters :

default_keys : int or list, optional

a default key or list of default keys

check(keys=None, check_for_control_keys=True)

Check if keypress is in event queue.

Parameters :

keys : int or list, optional

a specific key or list of keys to check

check_for_control_keys : bool, optional

checks if control key has been pressed (default=True)

Returns :

key : int

pressed key or None. Only the first occurence is returned!

clear()

Clear the event queue from keyboard events.

default_keys

Getter for default keys

logging

Getter for logging.

static process_control_keys(key_event=None)

Check if quit_key or pause_key has been pressed.

Reads pygame event cue if no key_event is specified.

Parameters :

key_event : int, optional

key event to check

Returns :

out : bool

True if quitting or pause screen has been displayed, False otherwise

read_out_buffered_keys()

Reads out all keydown events and clears queue.

set_logging(onoff)

Set logging of this object on or off

Parameters :

onoff : bool

set logging on (True) or off (False)

Notes

See also design.experiment.set_log_level fur further information about event logging.

wait(keys=None, duration=None, wait_for_keyup=False, check_for_control_keys=True)

Wait for keypress(es) (optionally for a certain amount of time).

This function will wait for a keypress and returns the found key as well as the reaction time. (This function clears the event queue!)

Parameters :

keys : int or list, optional

a specific key or list of keys to wait for

duration : int, optional

maximal time to wait in ms

wait_for_keyup : bool, optional

if True it waits for key-up

check_for_control_keys : bool, optional

checks if control key has been pressed (default=True)

Returns :

found : char

pressed charater

rt : int

reaction time in ms

wait_char(char, duration=None, check_for_control_keys=True)

Wait for character(s) (optionally for a certain amount of time).

This function will wait for one or more characters and returns the found character as well as the reaction time. (This function clears the event queue!)

Parameters :

char : int or list

a specific character or list of characters to wait for

duration : int, optional

maximal time to wait in ms

check_for_control_keys : bool, optional

checks if control key has been pressed (default=True)

Returns :

found : char

pressed charater

rt : int

reaction time in ms

Previous topic

expyriment.io.InputFile

Next topic

expyriment.io.MarkerOutput

This Page