Skip to content

Commit

Permalink
Merge pull request #26 from BoldBigflank/patch-1
Browse files Browse the repository at this point in the history
docs(keyboard): show keys.bind passes event
  • Loading branch information
straker committed Aug 31, 2018
2 parents eb8ac5c + 2cce032 commit b7423f7
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions docs/api/keyboard.html
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,13 @@ <h2 id="bind"><a href="#bind" class="section-link">kontra.keys&#8203;.bind(key)<
<dd>Function to call when the key is pressed.</dd>
</dl>

<p>Bind a set of keys to a function when pressed. Takes a single key or an array of keys.</p>
<p>Bind a set of keys to a function when pressed. Takes a single key or an array of keys. Passes the original event as a parameter.</p>

<pre><code class="language-javascript">kontra.keys.bind('p', function() {
// pause the game
});
kontra.keys.bind(['enter', 'space'], function() {
kontra.keys.bind(['enter', 'space'], function(e) {
e.preventDefault();
// fire gun
});</code></pre>

Expand Down Expand Up @@ -157,4 +158,4 @@ <h2 id="unbind"><a href="#unbind" class="section-link">kontra.keys&#8203;.unbind
</div>

</body>
</html>
</html>

0 comments on commit b7423f7

Please sign in to comment.