Skip to content

Commit 65ee635

Browse files
committed
Add Key documentation.
1 parent 26aa3c0 commit 65ee635

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

src/ui/Key.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@
1414
* All rights reserved.
1515
*/
1616

17+
/**
18+
* @namespace
19+
* @name Key
20+
*/
1721
var Key = this.Key = new function() {
1822
// TODO: make sure the keys are called the same as in Scriptographer
1923
// Missing: tab, cancel, clear, page-down, page-up, comma, minus, period,
@@ -127,8 +131,21 @@ var Key = this.Key = new function() {
127131
});
128132

129133
return {
134+
/** @lends Key */
135+
130136
modifiers: modifiers,
131137

138+
/**
139+
* Checks whether the specified key is pressed.
140+
*
141+
* @example
142+
* function onMouseDown(event) {
143+
* if(Key.isDown('shift')) {
144+
* console.log('The shift key is currently pressed.')
145+
* }
146+
* }
147+
* @return {boolean} true if the key is pressed, false otherwise
148+
*/
132149
isDown: function(key) {
133150
return !!keyMap[key];
134151
}

0 commit comments

Comments
 (0)