Constructor
new Keyboard(options)
- Source:
Parameters:
Name | Type | Description | ||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object |
Properties
|
Extends
- PsychObject
Members
(static, readonly) KeyStatus :Symbol
- Source:
Properties:
Name | Type | Description |
---|---|---|
KEY_DOWN |
Symbol | |
KEY_UP |
Symbol |
Keyboard KeyStatus.
Type:
- Symbol
Methods
(static) includes(keypressList, keyName) → {boolean}
- Source:
Test whether a list of KeyPress's contains one with a particular name.
Parameters:
Name | Type | Description |
---|---|---|
keypressList |
Array.<module:core.KeyPress> | list of KeyPress's |
keyName |
string | pyglet key name, e.g. 'escape', 'left' |
Returns:
whether or not a KeyPress with the given pyglet key name is present in the list
- Type
- boolean
(protected) _addKeyListeners()
- Source:
Add key listeners to the document.
clearEvents()
- Source:
Clear all events and resets the circular buffers.
getEvents() → {Array.<Keyboard.KeyEvent>}
- Source:
Get the list of those keyboard events still in the buffer, i.e. those that have not been previously cleared by calls to getKeys with clear = true.
Returns:
the list of events still in the buffer
- Type
- Array.<Keyboard.KeyEvent>
getKeys(options) → {Array.<KeyPress>}
- Source:
Get the list of keys pressed or pushed by the participant.
Parameters:
Name | Type | Description | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object |
Properties
|
Returns:
the list of keys that were pressed (keydown followed by keyup) or pushed (keydown with no subsequent keyup at the time getKeys is called).
- Type
- Array.<KeyPress>
start()
- Source:
Start recording keyboard events.
stop()
- Source:
Stop recording keyboard events.
Type Definitions
KeyEvent
- Source:
Properties:
Name | Type | Description |
---|---|---|
W3C |
string | key code |
W3C |
string | key |
pyglet |
string | key |
key |
module:core.Keyboard#KeyStatus | status |
timestamp |
number | (in seconds) |