1
0
mirror of https://github.com/psychopy/psychojs.git synced 2025-05-10 10:40:54 +00:00
psychojs/docs/module-core.Keyboard.html
2020-02-14 08:18:25 +01:00

1470 lines
20 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>JSDoc: Class: Keyboard</title>
<script src="scripts/prettify/prettify.js"> </script>
<script src="scripts/prettify/lang-css.js"> </script>
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
<link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
</head>
<body>
<div id="main">
<h1 class="page-title">Class: Keyboard</h1>
<section>
<header>
<h2><span class="attribs"><span class="type-signature"></span></span>
<span class="ancestors"><a href="module-core.html">core</a>.</span>Keyboard<span class="signature">(options)</span><span class="type-signature"></span></h2>
</header>
<article>
<div class="container-overview">
<h4 class="name" id="Keyboard"><span class="type-signature"></span>new Keyboard<span class="signature">(options)</span><span class="type-signature"></span></h4>
<div class="description">
<p>This manager handles all keyboard events. It is a substitute for the keyboard component of EventManager. </p>
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>options</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="description last">
<h6>Properties</h6>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Attributes</th>
<th>Default</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>psychoJS</code></td>
<td class="type">
<span class="param-type"><a href="module-core.PsychoJS.html">module:core.PsychoJS</a></span>
</td>
<td class="attributes">
</td>
<td class="default">
</td>
<td class="description last">the PsychoJS instance</td>
</tr>
<tr>
<td class="name"><code>bufferSize</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="attributes">
&lt;optional><br>
</td>
<td class="default">
10000
</td>
<td class="description last">the maximum size of the circular keyboard event buffer</td>
</tr>
<tr>
<td class="name"><code>waitForStart</code></td>
<td class="type">
<span class="param-type">boolean</span>
</td>
<td class="attributes">
&lt;optional><br>
</td>
<td class="default">
false
</td>
<td class="description last">whether or not to wait for a call to module:core.Keyboard#start
before recording keyboard events</td>
</tr>
<tr>
<td class="name"><code>clock</code></td>
<td class="type">
<span class="param-type">Clock</span>
</td>
<td class="attributes">
&lt;optional><br>
</td>
<td class="default">
</td>
<td class="description last">an optional clock</td>
</tr>
<tr>
<td class="name"><code>autoLog</code></td>
<td class="type">
<span class="param-type">boolean</span>
</td>
<td class="attributes">
</td>
<td class="default">
</td>
<td class="description last">whether or not to log</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="core_Keyboard.js.html">core/Keyboard.js</a>, <a href="core_Keyboard.js.html#line39">line 39</a>
</li></ul></dd>
</dl>
</div>
<h3 class="subsection-title">Members</h3>
<h4 class="name" id="KeyStatus"><span class="type-signature">(readonly) </span>KeyStatus<span class="type-signature"> :Symbol</span></h4>
<div class="description">
Keyboard KeyStatus.
</div>
<h5>Type:</h5>
<ul>
<li>
<span class="param-type">Symbol</span>
</li>
</ul>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="core_Keyboard.js.html">core/Keyboard.js</a>, <a href="core_Keyboard.js.html#line435">line 435</a>
</li></ul></dd>
</dl>
<h3 class="subsection-title">Methods</h3>
<h4 class="name" id="_addKeyListeners"><span class="type-signature">(private) </span>_addKeyListeners<span class="signature">()</span><span class="type-signature"></span></h4>
<div class="description">
Add key listeners to the document.
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="core_Keyboard.js.html">core/Keyboard.js</a>, <a href="core_Keyboard.js.html#line326">line 326</a>
</li></ul></dd>
</dl>
<h4 class="name" id="clearEvents"><span class="type-signature"></span>clearEvents<span class="signature">()</span><span class="type-signature"></span></h4>
<div class="description">
Clear all events and resets the circular buffers.
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="core_Keyboard.js.html">core/Keyboard.js</a>, <a href="core_Keyboard.js.html#line283">line 283</a>
</li></ul></dd>
</dl>
<h4 class="name" id="getEvents"><span class="type-signature"></span>getEvents<span class="signature">()</span><span class="type-signature"> &rarr; {Array.&lt;<a href="Keyboard.html#.KeyEvent">Keyboard.KeyEvent</a>>}</span></h4>
<div class="description">
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.
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="core_Keyboard.js.html">core/Keyboard.js</a>, <a href="core_Keyboard.js.html#line115">line 115</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
the list of events still in the buffer
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Array.&lt;<a href="Keyboard.html#.KeyEvent">Keyboard.KeyEvent</a>></span>
</dd>
</dl>
<h4 class="name" id="getKeys"><span class="type-signature"></span>getKeys<span class="signature">(options)</span><span class="type-signature"> &rarr; {Array.&lt;KeyPress>}</span></h4>
<div class="description">
Get the list of keys pressed or pushed by the participant.
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>options</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="description last">
<h6>Properties</h6>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Attributes</th>
<th>Default</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>keyList</code></td>
<td class="type">
<span class="param-type">Array.&lt;string></span>
</td>
<td class="attributes">
&lt;optional><br>
</td>
<td class="default">
[]
</td>
<td class="description last">the list of keys to consider. If keyList is empty, we consider all keys.
Note that we use pyglet keys here, to make the PsychoJs code more homogeneous with PsychoPy.</td>
</tr>
<tr>
<td class="name"><code>waitRelease</code></td>
<td class="type">
<span class="param-type">boolean</span>
</td>
<td class="attributes">
&lt;optional><br>
</td>
<td class="default">
true
</td>
<td class="description last">whether or not to include those keys pressed but not released. If
waitRelease = false, key presses without a corresponding key release will have an undefined duration.</td>
</tr>
<tr>
<td class="name"><code>clear</code></td>
<td class="type">
<span class="param-type">boolean</span>
</td>
<td class="attributes">
&lt;optional><br>
</td>
<td class="default">
false
</td>
<td class="description last">whether or not to keep in the buffer the key presses or pushes for a subsequent call to getKeys. If a keyList has been given and clear = true, we only remove from the buffer those keys in keyList</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="core_Keyboard.js.html">core/Keyboard.js</a>, <a href="core_Keyboard.js.html#line144">line 144</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
the list of keys that were pressed (keydown followed by keyup) or pushed
(keydown with no subsequent keyup at the time getKeys is called).
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Array.&lt;KeyPress></span>
</dd>
</dl>
<h4 class="name" id="includes"><span class="type-signature"></span>includes<span class="signature">(keypressList, keyName)</span><span class="type-signature"> &rarr; {boolean}</span></h4>
<div class="description">
Test whether a list of KeyPress's contains one with a particular name.
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>keypressList</code></td>
<td class="type">
<span class="param-type">Array.&lt;<a href="module-core.KeyPress.html">module:core.KeyPress</a>></span>
</td>
<td class="description last">list of KeyPress's</td>
</tr>
<tr>
<td class="name"><code>keyName</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="description last">pyglet key name, e.g. 'escape', 'left'</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="core_Keyboard.js.html">core/Keyboard.js</a>, <a href="core_Keyboard.js.html#line303">line 303</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
whether or not a KeyPress with the given pyglet key name is present in the list
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">boolean</span>
</dd>
</dl>
<h4 class="name" id="start"><span class="type-signature"></span>start<span class="signature">()</span><span class="type-signature"></span></h4>
<div class="description">
Start recording keyboard events.
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="core_Keyboard.js.html">core/Keyboard.js</a>, <a href="core_Keyboard.js.html#line80">line 80</a>
</li></ul></dd>
</dl>
<h4 class="name" id="stop"><span class="type-signature"></span>stop<span class="signature">()</span><span class="type-signature"></span></h4>
<div class="description">
Stop recording keyboard events.
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="core_Keyboard.js.html">core/Keyboard.js</a>, <a href="core_Keyboard.js.html#line93">line 93</a>
</li></ul></dd>
</dl>
</article>
</section>
</div>
<nav>
<h2><a href="index.html">Home</a></h2><h3>Modules</h3><ul><li><a href="module-core.html">core</a></li><li><a href="module-data.html">data</a></li><li><a href="module-sound.html">sound</a></li><li><a href="module-util.html">util</a></li><li><a href="module-visual.html">visual</a></li></ul><h3>Classes</h3><ul><li><a href="module-core.BuilderKeyResponse.html">BuilderKeyResponse</a></li><li><a href="module-core.EventManager.html">EventManager</a></li><li><a href="module-core.GUI.html">GUI</a></li><li><a href="module-core.Keyboard.html">Keyboard</a></li><li><a href="module-core.KeyPress.html">KeyPress</a></li><li><a href="module-core.Logger.html">Logger</a></li><li><a href="module-core.MinimalStim.html">MinimalStim</a></li><li><a href="module-core.Mouse.html">Mouse</a></li><li><a href="module-core.PsychoJS.html">PsychoJS</a></li><li><a href="module-core.ServerManager.html">ServerManager</a></li><li><a href="module-core.Window.html">Window</a></li><li><a href="module-data.ExperimentHandler.html">ExperimentHandler</a></li><li><a href="module-data.TrialHandler.html">TrialHandler</a></li><li><a href="module-sound.Sound.html">Sound</a></li><li><a href="module-sound.TonePlayer.html">TonePlayer</a></li><li><a href="module-sound.TrackPlayer.html">TrackPlayer</a></li><li><a href="module-util.Clock.html">Clock</a></li><li><a href="module-util.Color.html">Color</a></li><li><a href="module-util.CountdownTimer.html">CountdownTimer</a></li><li><a href="module-util.EventEmitter.html">EventEmitter</a></li><li><a href="module-util.MixinBuilder.html">MixinBuilder</a></li><li><a href="module-util.MonotonicClock.html">MonotonicClock</a></li><li><a href="module-util.PsychObject.html">PsychObject</a></li><li><a href="module-util.Scheduler.html">Scheduler</a></li><li><a href="module-visual.ImageStim.html">ImageStim</a></li><li><a href="module-visual.MovieStim.html">MovieStim</a></li><li><a href="module-visual.Polygon.html">Polygon</a></li><li><a href="module-visual.Rect.html">Rect</a></li><li><a href="module-visual.ShapeStim.html">ShapeStim</a></li><li><a href="module-visual.Slider.html">Slider</a></li><li><a href="module-visual.TextStim.html">TextStim</a></li><li><a href="module-visual.VisualStim.html">VisualStim</a></li></ul><h3>Interfaces</h3><ul><li><a href="module-sound.SoundPlayer.html">SoundPlayer</a></li></ul><h3>Mixins</h3><ul><li><a href="module-core.WindowMixin.html">WindowMixin</a></li><li><a href="module-util.ColorMixin.html">ColorMixin</a></li></ul>
</nav>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.3</a> on Fri Feb 14 2020 08:15:34 GMT+0100 (Central European Standard Time)
</footer>
<script> prettyPrint(); </script>
<script src="scripts/linenumber.js"> </script>
</body>
</html>