From e6ae6ff9f5b76d0e360d13e57945a4c2e7ca26c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E1=84=8B=E1=85=A2=E1=84=91=E1=85=B3=E1=86=AF=20=E1=84=82?= =?UTF-8?q?=E1=85=A9=E1=84=90=E1=85=B3=E1=84=87=E1=85=AE=E1=86=A8?= Date: Thu, 10 Jan 2019 17:22:27 +0900 Subject: [PATCH] Fix: chrome keyCode bug --- src/game/typing/practice/game.js | 2 ++ src/game/typing/whac_a_mole/game.js | 4 +++- src/game/typing/word_flyingsaucer/game.js | 5 +++-- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/game/typing/practice/game.js b/src/game/typing/practice/game.js index 9ea1d13..6c38630 100644 --- a/src/game/typing/practice/game.js +++ b/src/game/typing/practice/game.js @@ -377,6 +377,8 @@ var TypingPractice = { checkTypingContents: function(event) { var inputContent = event.key; + if(inputContent == undefined) + inputContent = String.fromCharCode(event.charCode); var typingContent = this.typingRandomContents[this.typingIndex]; if(this.isKeyPressed(inputContent, typingContent)) { diff --git a/src/game/typing/whac_a_mole/game.js b/src/game/typing/whac_a_mole/game.js index ac44c9e..de89f47 100644 --- a/src/game/typing/whac_a_mole/game.js +++ b/src/game/typing/whac_a_mole/game.js @@ -441,7 +441,9 @@ var WhacAMole = { checkTypingContents: function(event) { var inputContent = event.key; - var typingContent = this.typingRandomLetters[this.typingIndex]; + if(inputContent == undefined) + inputContent = String.fromCharCode(event.charCode); + var typingContent = this.typingRandomLetters[this.typingIndex]; if(this.isKeyPressed(inputContent, typingContent)) { var plusScore = this.hammer.getScore(); diff --git a/src/game/typing/word_flyingsaucer/game.js b/src/game/typing/word_flyingsaucer/game.js index ca8795d..c4e92f6 100644 --- a/src/game/typing/word_flyingsaucer/game.js +++ b/src/game/typing/word_flyingsaucer/game.js @@ -225,9 +225,10 @@ var WordFlyingSaucer = { checkTypingContents: function(event) { var count = this.flyingsaucers.length; - if(event.keyCode == Phaser.Keyboard.ENTER) { + if(event.keyCode == Phaser.KeyCode.ENTER || event.keyCode == Phaser.KeyCode.SPACEBAR) { + // console.log("event.keyCode : " + event.keyCode + "( " + Phaser.KeyCode.SPACEBAR + ")"); for(var i = 0; i < count; i++) { - this.flyingsaucers[i].checkWord(this.inputText.canvasInput.value()); + this.flyingsaucers[i].checkWord(this.inputText.canvasInput.value().trim()); } this.inputText.canvasInput.value("");