Skip to content

Commit cd8bb5a

Browse files
committed
Removed keyCode modifier (phaserjs#2542)
1 parent 57642af commit cd8bb5a

2 files changed

Lines changed: 2 additions & 34 deletions

File tree

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,6 @@ You can read all about the philosophy behind Lazer [here](http://phaser.io/news/
385385
* Group.addAt has been refactored to be a simple call to `Group.add`, removing lots of duplicate code in the process.
386386
* Group.create has a new optional argument `index` which controls the index within the group to insert the child to. Where 0 is the bottom of the Group. It also now makes proper use of `Group.add`, cutting down on more duplicate code.
387387
* Group.createMultiple now returns an Array containing references to all of the children that the method created.
388-
* Keyboard now uses a new internal method `getKeyCode` to normalize the key code value based on browser support. It first checks for `event.key`, then `event.keyIdentifier` and finally `event.keyCode` (thanks @SVasilev #2542)
389388

390389
### Bug Fixes
391390

src/input/Keyboard.js

Lines changed: 2 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -360,37 +360,6 @@ Phaser.Keyboard.prototype = {
360360

361361
},
362362

363-
/**
364-
* Normalises the keyCode value from the browser and returns it.
365-
*
366-
* This is based on browser support. It first checks for `event.key`, then `event.keyIdentifier`
367-
* and finally `event.keyCode`
368-
*
369-
* @method Phaser.Keyboard#getKeyCode
370-
* @param {KeyboardEvent} event
371-
* @private
372-
*/
373-
getKeyCode: function (event) {
374-
375-
if (event.key !== undefined)
376-
{
377-
return event.key;
378-
}
379-
else if (event.keyIdentifier !== undefined)
380-
{
381-
return event.keyIdentifier;
382-
}
383-
else if (event.keyCode !== undefined)
384-
{
385-
return event.keyCode;
386-
}
387-
else
388-
{
389-
return 0;
390-
}
391-
392-
},
393-
394363
/**
395364
* Process the keydown event.
396365
*
@@ -407,7 +376,7 @@ Phaser.Keyboard.prototype = {
407376
return;
408377
}
409378

410-
var key = this.getKeyCode(event);
379+
var key = event.keyCode;
411380

412381
// The event is being captured but another hotkey may need it
413382
if (this._capture[key])
@@ -470,7 +439,7 @@ Phaser.Keyboard.prototype = {
470439
return;
471440
}
472441

473-
var key = this.getKeyCode(event);
442+
var key = event.keyCode;
474443

475444
if (this._capture[key])
476445
{

0 commit comments

Comments
 (0)