@@ -4,53 +4,113 @@ var Key = require('./keys/Key');
44var KeyCodes = require ( './keys/KeyCodes' ) ;
55var KeyCombo = require ( './combo/KeyCombo' ) ;
66var KeyMap = require ( './keys/KeyMap' ) ;
7- var ProcessKeyCombo = require ( './combo/ProcessKeyCombo' ) ;
87var ProcessKeyDown = require ( './keys/ProcessKeyDown' ) ;
98var ProcessKeyUp = require ( './keys/ProcessKeyUp' ) ;
109
11- /**
12- * The Keyboard class monitors keyboard input and dispatches keyboard events.
13- *
14- * _Note_: many keyboards are unable to process certain combinations of keys due to hardware limitations known as ghosting.
15- * See http://www.html5gamedevs.com/topic/4876-impossible-to-use-more-than-2-keyboard-input-buttons-at-the-same-time/ for more details.
16- *
17- * Also please be aware that certain browser extensions can disable or override Phaser keyboard handling.
18- * For example the Chrome extension vimium is known to disable Phaser from using the D key. And there are others.
19- * So please check your extensions before opening Phaser issues.
20- */
21-
2210var KeyboardManager = new Class ( {
2311
2412 Extends : EventEmitter ,
2513
2614 initialize :
2715
16+ /**
17+ * The Keyboard class monitors keyboard input and dispatches keyboard events.
18+ *
19+ * _Note_: many keyboards are unable to process certain combinations of keys due to hardware limitations known as ghosting.
20+ * See http://www.html5gamedevs.com/topic/4876-impossible-to-use-more-than-2-keyboard-input-buttons-at-the-same-time/ for more details.
21+ *
22+ * Also please be aware that certain browser extensions can disable or override Phaser keyboard handling.
23+ * For example the Chrome extension vimium is known to disable Phaser from using the D key. And there are others.
24+ * So please check your extensions before opening Phaser issues.
25+ *
26+ * @class KeyboardManager
27+ * @extends eventemitter3
28+ * @memberOf Phaser.Input.Keyboard
29+ * @constructor
30+ * @since 3.0.0
31+ *
32+ * @param {Phaser.Input.InputManager } inputManager - [description]
33+ */
2834 function KeyboardManager ( inputManager )
2935 {
3036 EventEmitter . call ( this ) ;
3137
38+ /**
39+ * [description]
40+ *
41+ * @property {Phaser.Input.InputManager } manager
42+ * @since 3.0.0
43+ */
3244 this . manager = inputManager ;
3345
46+ /**
47+ * [description]
48+ *
49+ * @property {boolean } enabled
50+ * @default false
51+ * @since 3.0.0
52+ */
3453 this . enabled = false ;
3554
55+ /**
56+ * [description]
57+ *
58+ * @property {null } target
59+ * @since 3.0.0
60+ */
3661 this . target ;
3762
63+ /**
64+ * [description]
65+ *
66+ * @property {array } keys
67+ * @default []
68+ * @since 3.0.0
69+ */
3870 this . keys = [ ] ;
3971
72+ /**
73+ * [description]
74+ *
75+ * @property {array } combos
76+ * @default []
77+ * @since 3.0.0
78+ */
4079 this . combos = [ ] ;
4180
81+ /**
82+ * [description]
83+ *
84+ * @property {array } captures
85+ * @default []
86+ * @since 3.0.0
87+ */
4288 this . captures = [ ] ;
4389
44- // Standard FIFO queue
90+ /**
91+ * [description]
92+ *
93+ * @property {array } queue
94+ * @default []
95+ * @since 3.0.0
96+ */
4597 this . queue = [ ] ;
4698
99+ /**
100+ * [description]
101+ *
102+ * @property {any } handler
103+ * @since 3.0.0
104+ */
47105 this . handler ;
48106 } ,
49107
50108 /**
51- * The Boot handler is called by Phaser.Game when it first starts up.
52- * The renderer is available by now.
53- */
109+ * The Boot handler is called by Phaser.Game when it first starts up.
110+ *
111+ * @method Phaser.Input.Keyboard.KeyboardManager#boot
112+ * @since 3.0.0
113+ */
54114 boot : function ( )
55115 {
56116 var config = this . manager . config ;
@@ -64,6 +124,14 @@ var KeyboardManager = new Class({
64124 }
65125 } ,
66126
127+ /**
128+ * [description]
129+ *
130+ * @method Phaser.Input.Keyboard.KeyboardManager#startListeners
131+ * @since 3.0.0
132+ *
133+ * @return {[type] } [description]
134+ */
67135 startListeners : function ( )
68136 {
69137 var queue = this . queue ;
@@ -91,15 +159,26 @@ var KeyboardManager = new Class({
91159 this . target . addEventListener ( 'keyup' , handler , false ) ;
92160 } ,
93161
162+ /**
163+ * [description]
164+ *
165+ * @method Phaser.Input.Keyboard.KeyboardManager#stopListeners
166+ * @since 3.0.0
167+ */
94168 stopListeners : function ( )
95169 {
96170 this . target . removeEventListener ( 'keydown' , this . handler ) ;
97171 this . target . removeEventListener ( 'keyup' , this . handler ) ;
98172 } ,
99173
100174 /**
101- * Creates and returns an object containing 4 hotkeys for Up, Down, Left and Right and also space and shift.
102- */
175+ * Creates and returns an object containing 4 hotkeys for Up, Down, Left and Right, and also space and shift.
176+ *
177+ * @method Phaser.Input.Keyboard.KeyboardManager#createCursorKeys
178+ * @since 3.0.0
179+ *
180+ * @return {[type] } [description]
181+ */
103182 createCursorKeys : function ( )
104183 {
105184 return this . addKeys ( {
@@ -113,14 +192,21 @@ var KeyboardManager = new Class({
113192 } ,
114193
115194 /**
116- * A practical way to create an object containing user selected hotkeys.
117- *
118- * For example,
119- *
120- * addKeys( { 'up': Phaser.KeyCode.W, 'down': Phaser.KeyCode.S, 'left': Phaser.KeyCode.A, 'right': Phaser.KeyCode.D } );
121- *
122- * would return an object containing properties (`up`, `down`, `left` and `right`) referring to {@link Phaser.Key} object.
123- */
195+ * A practical way to create an object containing user selected hotkeys.
196+ *
197+ * For example,
198+ *
199+ * addKeys( { 'up': Phaser.KeyCode.W, 'down': Phaser.KeyCode.S, 'left': Phaser.KeyCode.A, 'right': Phaser.KeyCode.D } );
200+ *
201+ * would return an object containing properties (`up`, `down`, `left` and `right`) referring to {@link Phaser.Key} object.
202+ *
203+ * @method Phaser.Input.Keyboard.KeyboardManager#addKeys
204+ * @since 3.0.0
205+ *
206+ * @param {[type] } keys - [description]
207+ *
208+ * @return {[type] } [description]
209+ */
124210 addKeys : function ( keys )
125211 {
126212 var output = { } ;
@@ -134,9 +220,16 @@ var KeyboardManager = new Class({
134220 } ,
135221
136222 /**
137- * If you need more fine-grained control over a Key you can create a new Phaser.Key object via this method.
138- * The Key object can then be polled, have events attached to it, etc.
139- */
223+ * If you need more fine-grained control over a Key you can create a new Phaser.Key object via this method.
224+ * The Key object can then be polled, have events attached to it, etc.
225+ *
226+ * @method Phaser.Input.Keyboard.KeyboardManager#addKey
227+ * @since 3.0.0
228+ *
229+ * @param {[type] } keyCode - [description]
230+ *
231+ * @return {[type] } [description]
232+ */
140233 addKey : function ( keyCode )
141234 {
142235 var keys = this . keys ;
@@ -151,8 +244,13 @@ var KeyboardManager = new Class({
151244 } ,
152245
153246 /**
154- * Removes a Key object from the Keyboard manager.
155- */
247+ * Removes a Key object from the Keyboard manager.
248+ *
249+ * @method Phaser.Input.Keyboard.KeyboardManager#removeKey
250+ * @since 3.0.0
251+ *
252+ * @param {[type] } keyCode - [description]
253+ */
156254 removeKey : function ( keyCode )
157255 {
158256 if ( this . keys [ keyCode ] )
@@ -162,6 +260,14 @@ var KeyboardManager = new Class({
162260 }
163261 } ,
164262
263+ /**
264+ * [description]
265+ *
266+ * @method Phaser.Input.Keyboard.KeyboardManager#addKeyCapture
267+ * @since 3.0.0
268+ *
269+ * @param {[type] } keyCodes - [description]
270+ */
165271 addKeyCapture : function ( keyCodes )
166272 {
167273 if ( ! Array . isArray ( keyCodes ) )
@@ -175,6 +281,14 @@ var KeyboardManager = new Class({
175281 }
176282 } ,
177283
284+ /**
285+ * [description]
286+ *
287+ * @method Phaser.Input.Keyboard.KeyboardManager#removeKeyCapture
288+ * @since 3.0.0
289+ *
290+ * @param {[type] } keyCodes - [description]
291+ */
178292 removeKeyCapture : function ( keyCodes )
179293 {
180294 if ( ! Array . isArray ( keyCodes ) )
@@ -188,15 +302,30 @@ var KeyboardManager = new Class({
188302 }
189303 } ,
190304
305+ /**
306+ * [description]
307+ *
308+ * @method Phaser.Input.Keyboard.KeyboardManager#createCombo
309+ * @since 3.0.0
310+ *
311+ * @param {[type] } keys - [description]
312+ * @param {[type] } config - [description]
313+ *
314+ * @return {[type] } [description]
315+ */
191316 createCombo : function ( keys , config )
192317 {
193318 return new KeyCombo ( this , keys , config ) ;
194319 } ,
195320
196- // https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/KeyboardEvent
197- // type = 'keydown', 'keyup'
198- // keyCode = integer
199-
321+ /**
322+ * [description]
323+ *
324+ * @method Phaser.Input.Keyboard.KeyboardManager#update
325+ * @since 3.0.0
326+ *
327+ * @return {[type] } [description]
328+ */
200329 update : function ( )
201330 {
202331 var len = this . queue . length ;
@@ -245,11 +374,23 @@ var KeyboardManager = new Class({
245374 }
246375 } ,
247376
377+ /**
378+ * [description]
379+ *
380+ * @method Phaser.Input.Keyboard.KeyboardManager#shutdown
381+ * @since 3.0.0
382+ */
248383 shutdown : function ( )
249384 {
250385 this . removeAllListeners ( ) ;
251386 } ,
252387
388+ /**
389+ * [description]
390+ *
391+ * @method Phaser.Input.Keyboard.KeyboardManager#destroy
392+ * @since 3.0.0
393+ */
253394 destroy : function ( )
254395 {
255396 this . stopListeners ( ) ;
0 commit comments