expyfun.get_keyboard_input#

expyfun.get_keyboard_input(prompt, default=None, out_type=<class 'str'>, valid=None)[source]#

Get keyboard input of a specific type

Parameters:
promptstr

Prompt to use.

defaultobject | None

If user enters nothing, this will be used. If None, the user will be repeatedly prompted until a valid response is found.

out_typetype

Type to coerce to. If coercion fails, the user will be prompted again.

validlist | None

An iterable that contains all the allowable inputs. Keeps asking until it recceives a valid input. Does not check if None.

Returns:
responseof type out_type

The user response.

Examples using expyfun.get_keyboard_input#

Run a simple experiment

Run a simple experiment