From eb497f59c8d85b2fe81f9775dc3cf52de99c1021 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: Wed, 13 Jun 2018 23:05:39 +0900 Subject: [PATCH] Fix: change key input value -> keyCode --- .../typing/practice/english_key_mapper.js | 52 ++-- src/game/typing/practice/key_button.js | 163 +++++++----- src/game/typing/practice/key_mapper.js | 90 ++++--- src/game/typing/practice/keyboard.js | 232 ++++++++++-------- src/game/typing/practice/korean_key_mapper.js | 52 ++-- test/key_mapper.js | 62 ++--- 6 files changed, 370 insertions(+), 281 deletions(-) diff --git a/src/game/typing/practice/english_key_mapper.js b/src/game/typing/practice/english_key_mapper.js index efbc1ce..42bf2fe 100644 --- a/src/game/typing/practice/english_key_mapper.js +++ b/src/game/typing/practice/english_key_mapper.js @@ -3,34 +3,34 @@ class EnglishKeyMapper extends KeyMapper { constructor() { super(); - this.registerKeyTextData("q", "q", "Q", KeyTextData.RIGHT_HAND); - this.registerKeyTextData("w", "w", "W", KeyTextData.RIGHT_HAND); - this.registerKeyTextData("e", "e", "E", KeyTextData.RIGHT_HAND); - this.registerKeyTextData("r", "r", "R", KeyTextData.RIGHT_HAND); - this.registerKeyTextData("t", "t", "T", KeyTextData.RIGHT_HAND); - this.registerKeyTextData("y", "y", "Y", KeyTextData.LEFT_HAND); - this.registerKeyTextData("u", "u", "U", KeyTextData.LEFT_HAND); - this.registerKeyTextData("i", "i", "I", KeyTextData.LEFT_HAND); - this.registerKeyTextData("o", "o", "O", KeyTextData.LEFT_HAND); - this.registerKeyTextData("p", "p", "P", KeyTextData.LEFT_HAND); + this.registerKeyTextData("KeyQ", "q", "Q"); + this.registerKeyTextData("KeyW", "w", "W"); + this.registerKeyTextData("KeyE", "e", "E"); + this.registerKeyTextData("KeyR", "r", "R"); + this.registerKeyTextData("KeyT", "t", "T"); + this.registerKeyTextData("KeyY", "y", "Y"); + this.registerKeyTextData("KeyU", "u", "U"); + this.registerKeyTextData("KeyI", "i", "I"); + this.registerKeyTextData("KeyO", "o", "O"); + this.registerKeyTextData("KeyP", "p", "P"); - this.registerKeyTextData("a", "a", "A", KeyTextData.RIGHT_HAND); - this.registerKeyTextData("s", "s", "S", KeyTextData.RIGHT_HAND); - this.registerKeyTextData("d", "d", "D", KeyTextData.RIGHT_HAND); - this.registerKeyTextData("f", "f", "F", KeyTextData.RIGHT_HAND); - this.registerKeyTextData("g", "g", "G", KeyTextData.RIGHT_HAND); - this.registerKeyTextData("h", "h", "H", KeyTextData.LEFT_HAND); - this.registerKeyTextData("j", "j", "J", KeyTextData.LEFT_HAND); - this.registerKeyTextData("k", "k", "K", KeyTextData.LEFT_HAND); - this.registerKeyTextData("l", "l", "L", KeyTextData.LEFT_HAND); + this.registerKeyTextData("KeyA", "a", "A"); + this.registerKeyTextData("KeyS", "s", "S"); + this.registerKeyTextData("KeyD", "d", "D"); + this.registerKeyTextData("KeyF", "f", "F"); + this.registerKeyTextData("KeyG", "g", "G"); + this.registerKeyTextData("KeyH", "h", "H"); + this.registerKeyTextData("KeyJ", "j", "J"); + this.registerKeyTextData("KeyK", "k", "K"); + this.registerKeyTextData("KeyL", "l", "L"); - this.registerKeyTextData("z", "z", "Z", KeyTextData.RIGHT_HAND); - this.registerKeyTextData("x", "x", "X", KeyTextData.RIGHT_HAND); - this.registerKeyTextData("c", "c", "C", KeyTextData.RIGHT_HAND); - this.registerKeyTextData("v", "v", "V", KeyTextData.RIGHT_HAND); - this.registerKeyTextData("b", "b", "B", KeyTextData.RIGHT_HAND); - this.registerKeyTextData("n", "n", "N", KeyTextData.LEFT_HAND); - this.registerKeyTextData("m", "m", "M", KeyTextData.LEFT_HAND); + this.registerKeyTextData("KeyZ", "z", "Z"); + this.registerKeyTextData("KeyX", "x", "X"); + this.registerKeyTextData("KeyC", "c", "C"); + this.registerKeyTextData("KeyV", "v", "V"); + this.registerKeyTextData("KeyB", "b", "B"); + this.registerKeyTextData("KeyN", "n", "N"); + this.registerKeyTextData("KeyM", "m", "M"); } } \ No newline at end of file diff --git a/src/game/typing/practice/key_button.js b/src/game/typing/practice/key_button.js index 4f2d0b7..66bedfc 100644 --- a/src/game/typing/practice/key_button.js +++ b/src/game/typing/practice/key_button.js @@ -11,68 +11,21 @@ class KeyButton { this.setting.strokeWidthPx = 2; this.buttonSolid = this.makeButtonSolidSprite(this.setting); - if(handSide == KeyButton.LEFT_HAND) - this.setNormalColor(); - else - this.setPressedColor(); + this.setNormalColor(); this.buttonStroke = this.makeButtonStrokeSprite(this.setting); + this.baselineStroke = null; + if(fingerType == KeyButton.INDEX_FINGER_BASELINE) { + this.baselineStroke = this.makeBaselineStrokeSprite(this.setting, width, height); + this.buttonStroke.addChild(this.baselineStroke); + } + this.buttonText = this.makeText(this.setting, this.normalText); if(this.normalText.length > 0) { this.buttonStroke.addChild(this.buttonText); } } - setNormalColor() { - switch(this.fingerType) { - case KeyButton.THUMB: - this.buttonSolid.tint = 0x604d4d; - break; - - case KeyButton.INDEX_FINGER: - this.buttonSolid.tint = 0x4d604d; - break; - - case KeyButton.MIDDLE_FINGER: - this.buttonSolid.tint = 0x4d4d60; - break; - - case KeyButton.RING_FINGER: - this.buttonSolid.tint = 0x60604d; - break; - - case KeyButton.LITTLE_FINGER: - this.buttonSolid.tint = 0x4d6060; - break; - - } - } - - setPressedColor() { - switch(this.fingerType) { - case KeyButton.THUMB: - this.buttonSolid.tint = 0xff8080; - break; - - case KeyButton.INDEX_FINGER: - this.buttonSolid.tint = 0x80ff80; - break; - - case KeyButton.MIDDLE_FINGER: - this.buttonSolid.tint = 0x8080ff; - break; - - case KeyButton.RING_FINGER: - this.buttonSolid.tint = 0xffff80; - break; - - case KeyButton.LITTLE_FINGER: - this.buttonSolid.tint = 0x80ffff; - break; - - } - } - makeButtonSolidSprite(setting) { let btnTexture = new Phaser.Graphics() .beginFill(0xffffff, 0.5) @@ -101,6 +54,27 @@ class KeyButton { ); } + makeBaselineStrokeSprite(setting, width, height) { + let strokePx = setting.strokeWidthPx; + + let baselineTexture = new Phaser.Graphics() + .lineStyle(2, 0x888888) + .moveTo(1, 1) + .lineTo(16, 1) + .lineStyle(2, 0xffffff) + .moveTo(0, 0) + .lineTo(15, 0) + .generateTexture(); + + let baselineSprite = game.add.sprite( + strokePx + setting.width / 2, + strokePx + setting.height - 6, + baselineTexture + ); + baselineSprite.anchor.set(0.5); + return baselineSprite; + } + makeText(setting, textContent) { let offsetX_px = 4; let offsetY_px = 5; @@ -138,6 +112,72 @@ class KeyButton { } + setNormalColor() { + switch(this.fingerType) { + case KeyButton.THUMB: + this.buttonSolid.tint = 0x604d4d; + break; + + case KeyButton.INDEX_FINGER: + case KeyButton.INDEX_FINGER_BASELINE: + this.buttonSolid.tint = 0x4d604d; + break; + + case KeyButton.MIDDLE_FINGER: + this.buttonSolid.tint = 0x4d4d60; + break; + + case KeyButton.RING_FINGER: + this.buttonSolid.tint = 0x60604d; + break; + + case KeyButton.LITTLE_FINGER: + this.buttonSolid.tint = 0x4d6060; + break; + + default: + this.buttonSolid.tint = 0x4d4d4d; + // this.buttonSolid.alpha = 0; + } + } + + setTargetColor() { + switch(this.fingerType) { + case KeyButton.THUMB: + this.buttonSolid.tint = 0xff8080; + break; + + case KeyButton.INDEX_FINGER: + case KeyButton.INDEX_FINGER_BASELINE: + this.buttonSolid.tint = 0x80ff80; + break; + + case KeyButton.MIDDLE_FINGER: + this.buttonSolid.tint = 0x8080ff; + break; + + case KeyButton.RING_FINGER: + this.buttonSolid.tint = 0xffff80; + break; + + case KeyButton.LITTLE_FINGER: + this.buttonSolid.tint = 0x80ffff; + break; + + default: + this.buttonSolid.tint = 0x202020; + // this.buttonSolid.alpha = 0; + } + } + + setGoodPressColor() { + this.buttonSolid.tint = 0x0000ff; + } + + setBadPressColor() { + this.buttonSolid.tint = 0xff0000; + } + onShiftPressed() { this.buttonText.text = this.shiftText; @@ -148,7 +188,7 @@ class KeyButton { } - +/* mouseOut() { this.text.fill = this.setting.textColors.out; this.buttonStroke.tint = this.setting.strokeColors.out; @@ -184,6 +224,7 @@ class KeyButton { this.buttonIcon.tint = this.setting.strokeColors.disabled; } } +*/ } @@ -204,8 +245,10 @@ KeyButton.LEFT_HAND = 1; KeyButton.RIGHT_HAND = 2; KeyButton.BOTH_HAND = 3; -KeyButton.THUMB = 0; -KeyButton.INDEX_FINGER = 1; -KeyButton.MIDDLE_FINGER = 2; -KeyButton.RING_FINGER = 3; -KeyButton.LITTLE_FINGER = 4; \ No newline at end of file +KeyButton.NONE_FINGER = 0; +KeyButton.THUMB = 1; +KeyButton.INDEX_FINGER = 2; +KeyButton.INDEX_FINGER_BASELINE = 3; +KeyButton.MIDDLE_FINGER = 4; +KeyButton.RING_FINGER = 5; +KeyButton.LITTLE_FINGER = 5; \ No newline at end of file diff --git a/src/game/typing/practice/key_mapper.js b/src/game/typing/practice/key_mapper.js index 55593b0..687696f 100644 --- a/src/game/typing/practice/key_mapper.js +++ b/src/game/typing/practice/key_mapper.js @@ -1,9 +1,8 @@ class KeyTextData { - constructor(normalText, shiftText, shiftHandSide) { + constructor(normalText, shiftText) { this.normalText = normalText; this.shiftText = shiftText; - this.shiftHandSide = shiftHandSide; } } @@ -14,50 +13,54 @@ class KeyMapper { this.keyboardKeyMap = {}; this.inputKeyMap = {}; - this.registerKeyTextData("`", "`", "~", KeyTextData.RIGHT_HAND); - this.registerKeyTextData("1", "1", "!", KeyTextData.RIGHT_HAND); - this.registerKeyTextData("2", "2", "@", KeyTextData.RIGHT_HAND); - this.registerKeyTextData("3", "3", "#", KeyTextData.RIGHT_HAND); - this.registerKeyTextData("4", "4", "$", KeyTextData.RIGHT_HAND); - this.registerKeyTextData("5", "5", "%", KeyTextData.RIGHT_HAND); - this.registerKeyTextData("6", "6", "^", KeyTextData.LEFT_HAND); - this.registerKeyTextData("7", "7", "&", KeyTextData.LEFT_HAND); - this.registerKeyTextData("8", "8", "*", KeyTextData.LEFT_HAND); - this.registerKeyTextData("9", "9", "(", KeyTextData.LEFT_HAND); - this.registerKeyTextData("0", "0", ")", KeyTextData.LEFT_HAND); - this.registerKeyTextData("-", "-", "_", KeyTextData.LEFT_HAND); - this.registerKeyTextData("=", "=", "+", KeyTextData.LEFT_HAND); - this.registerKeyTextData("backspace", "backspace", "backspace", KeyTextData.NONE_HAND); + this.registerKeyTextData("Backquote", "`", "~"); + this.registerKeyTextData("Digit1", "1", "!"); + this.registerKeyTextData("Digit2", "2", "@"); + this.registerKeyTextData("Digit3", "3", "#"); + this.registerKeyTextData("Digit4", "4", "$"); + this.registerKeyTextData("Digit5", "5", "%"); + this.registerKeyTextData("Digit6", "6", "^"); + this.registerKeyTextData("Digit7", "7", "&"); + this.registerKeyTextData("Digit8", "8", "*"); + this.registerKeyTextData("Digit9", "9", "("); + this.registerKeyTextData("Digit0", "0", ")"); + this.registerKeyTextData("Minus", "-", "_"); + this.registerKeyTextData("Equal", "=", "+"); + this.registerKeyTextData("Backspace", "backspace", "backspace"); - this.registerKeyTextData("tab", "tab", "tab", KeyTextData.NONE_HAND); - this.registerKeyTextData("[", "[", "{", KeyTextData.LEFT_HAND); - this.registerKeyTextData("]", "]", "}", KeyTextData.LEFT_HAND); - this.registerKeyTextData("\\", "\\", "|", KeyTextData.LEFT_HAND); + this.registerKeyTextData("Tab", "tab", "tab"); + this.registerKeyTextData("BracketLeft", "[", "{"); + this.registerKeyTextData("BracketRight", "]", "}"); + this.registerKeyTextData("Backslash", "\\", "|"); - this.registerKeyTextData("caps_lock", "caps lock", "caps lock", KeyTextData.NONE_HAND); - this.registerKeyTextData(";", ";", ":", KeyTextData.LEFT_HAND); - this.registerKeyTextData("'", "'", "\"", KeyTextData.LEFT_HAND); - this.registerKeyTextData("enter", "enter", "enter", KeyTextData.NONE_HAND); + this.registerKeyTextData("CapsLock", "caps lock", "caps lock"); + this.registerKeyTextData("Semicolon", ";", ":"); + this.registerKeyTextData("Quote", "'", "\""); + this.registerKeyTextData("Enter", "enter", "enter"); - this.registerKeyTextData("left_shift", "left_shift", "left_shift", KeyTextData.LEFT_HAND); - this.registerKeyTextData("right_shift", "right_shift", "right_shift", KeyTextData.RIGHT_HAND); - this.registerKeyTextData(",", ",", "<", KeyTextData.LEFT_HAND); - this.registerKeyTextData(".", ".", ">", KeyTextData.LEFT_HAND); - this.registerKeyTextData("/", "/", "?", KeyTextData.LEFT_HAND); + this.registerKeyTextData("ShiftLeft", "left_shift", "left_shift"); + this.registerKeyTextData("ShiftRight", "right_shift", "right_shift"); + this.registerKeyTextData("Comma", ",", "<"); + this.registerKeyTextData("Period", ".", ">"); + this.registerKeyTextData("Slash", "/", "?"); - this.registerKeyTextData("left_ctrl", "ctrl", "ctrl", KeyTextData.NONE_HAND); - this.registerKeyTextData("window", "window", "window", KeyTextData.NONE_HAND); - this.registerKeyTextData("left_alt", "alt", "alt", KeyTextData.NONE_HAND); - this.registerKeyTextData("chinese", "한자", "한자", KeyTextData.NONE_HAND); - this.registerKeyTextData("space", "space", "space", KeyTextData.BOTH_HAND); - this.registerKeyTextData("korean_english", "한/영", "한/영", KeyTextData.NONE_HAND); - this.registerKeyTextData("right_alt", "alt", "alt", KeyTextData.NONE_HAND); - this.registerKeyTextData("right_ctrl", "ctrl", "ctrl", KeyTextData.NONE_HAND); + this.registerKeyTextData("ControlLeft", "ctrl", "ctrl"); + this.registerKeyTextData("window", "window", "window"); + this.registerKeyTextData("AltLeft", "alt", "alt"); + this.registerKeyTextData("chinese", "한자", "한자"); + this.registerKeyTextData("Space", "space", "space"); + this.registerKeyTextData("korean_english", "한/영", "한/영"); + this.registerKeyTextData("AltRight", "alt", "alt"); + this.registerKeyTextData("ControlRight", "ctrl", "ctrl"); + + console.log(this.keyboardKeyMap); } registerKeyTextData(keyID, normalText, shiftText, shiftHandSide) { this.keyboardKeyMap[keyID] = new KeyTextData(normalText, shiftText, shiftHandSide); + if(this.inputKeyMap[keyID] === undefined) + this.inputKeyMap[keyID] = keyID; if(this.inputKeyMap[normalText] === undefined) this.inputKeyMap[normalText] = keyID; if(this.inputKeyMap[shiftText] === undefined) @@ -66,15 +69,26 @@ class KeyMapper { getNormalText(keyID) { - // console.log(this.keyboardKeyMap[keyID]); + if(this.keyboardKeyMap[keyID] === undefined) { + console.log(keyID); + return "?"; + } return this.keyboardKeyMap[keyID].normalText; } getShiftText(keyID) { + if(this.keyboardKeyMap[keyID] === undefined) { + console.log(keyID); + return "?"; + } return this.keyboardKeyMap[keyID].shiftText; } getShiftHandSide(keyID) { + if(this.keyboardKeyMap[keyID] === undefined) { + console.log(keyID); + return "?"; + } return this.keyboardKeyMap[keyID].shiftHandSide; } diff --git a/src/game/typing/practice/keyboard.js b/src/game/typing/practice/keyboard.js index c7ad132..dfa79b2 100644 --- a/src/game/typing/practice/keyboard.js +++ b/src/game/typing/practice/keyboard.js @@ -1,19 +1,24 @@ class Keyboard { constructor(keyMapper) { - // let keyButton = new KeyButton(100, 400, 100, "A", "align_type"); - // let keyData = this.getKeyBoardData(keyMapper); + this.keyMapper = keyMapper; this.keyIndex = 0; this.keyDataList = []; this.keyList = []; - this.keyHash = {}; + + this.allKeyHash = {}; + this.normalKeyHash = {}; + + this.keyUpReservations = []; + + game.input.keyboard.addCallbacks(this, this.keyDown, this.keyUp, null); let shiftKey = game.input.keyboard.addKey(Phaser.KeyCode.SHIFT); shiftKey.onDown.add(this.shifted, this); shiftKey.onUp.add(this.unshifted, this); - this.initKeyData(keyMapper); + this.initKeyData(); for(let i = 0; i < this.keyDataList.length; i++) { this.keyList[i] = new KeyButton( @@ -27,9 +32,46 @@ class Keyboard { this.keyDataList[i].fingerType, this.keyDataList[i].alignType, ); + + this.allKeyHash[this.keyDataList[i].keyID] = this.keyList[i]; } } + keyDown(char) { + let keyCode = char.code; + this.setPressedSprite(keyCode); + } + + setPressedSprite(keyCode) { + let keyID = this.keyMapper.getKeyIDOfText(keyCode); + let key = this.allKeyHash[keyID]; + if(key !== undefined) { + if(keyCode === "Tab" || keyCode === "CapsLock" || keyCode === "MetaLeft" || keyCode === "MetaRight") { + // game.time.events.add(Phaser.Timer.SECOND, () => this.onKeyUp(key), this); + console.log(keyCode + " is pressed but not show"); + return; + } + + key.setTargetColor(); + } else { + console.log(keyCode+ " is pressed but not registered to KeyMapper"); + } + } + + keyUp(char) { + let keyCode = char.code; + this.setNormalSprite(keyCode); + } + + setNormalSprite(keyCode) { + let keyID = this.keyMapper.getKeyIDOfText(keyCode); + let key = this.allKeyHash[keyID]; + if(key !== undefined) + key.setNormalColor(); + } + + + shifted() { for(let i = 0; i < this.keyDataList.length; i++) { this.keyList[i].onShiftPressed(); @@ -51,8 +93,9 @@ class Keyboard { } - makeKeyDataObject(normalText, shiftText, handSide, fingerType, x, y, width, height, alignType) { + makeKeyDataObject(keyID, normalText, shiftText, handSide, fingerType, x, y, width, height, alignType) { let keyDataObject = {}; + keyDataObject.keyID = keyID; keyDataObject.normalText = normalText; keyDataObject.shiftText = shiftText; keyDataObject.handSide = handSide; @@ -66,8 +109,9 @@ class Keyboard { return keyDataObject; } - makeNextNormalKeyDataObject(prevKeyData, normalText, shiftText, handSide, fingerType) { + makeNextNormalKeyDataObject(keyID, prevKeyData, normalText, shiftText, handSide, fingerType) { return this.makeKeyDataObject( + keyID, normalText, shiftText, handSide, @@ -81,11 +125,12 @@ class Keyboard { } - addFunctionKeyData(keyMapper, keyID, handSide, fingerType, x, y, width, height, type) { - let normalText = keyMapper.getNormalText(keyID); - let shiftText = keyMapper.getShiftText(keyID); + addFunctionKeyData(keyID, handSide, fingerType, x, y, width, height, type) { + let normalText = this.keyMapper.getNormalText(keyID); + let shiftText = this.keyMapper.getShiftText(keyID); let newKey = this.makeKeyDataObject( + keyID, normalText, shiftText, handSide, fingerType, x, y, @@ -94,16 +139,15 @@ class Keyboard { ); this.keyDataList[this.keyIndex] = newKey; this.keyIndex++; - - this.keyHash[keyID] = newKey; } - addNextFunctionKeyData(keyMapper, keyID, handSide, fingerType, width, height, type) { + addNextFunctionKeyData(keyID, handSide, fingerType, width, height, type) { let prevKey = this.keyDataList[this.keyIndex - 1]; - let normalText = keyMapper.getNormalText(keyID); - let shiftText = keyMapper.getShiftText(keyID); + let normalText = this.keyMapper.getNormalText(keyID); + let shiftText = this.keyMapper.getShiftText(keyID); let newKey = this.makeKeyDataObject( + keyID, normalText, shiftText, handSide, fingerType, prevKey.x + prevKey.width + Keyboard.KEY_GAP_PX, prevKey.y, @@ -113,15 +157,16 @@ class Keyboard { this.keyDataList[this.keyIndex] = newKey; this.keyIndex++; - this.keyHash[keyID] = newKey; + // this.normalKeyHash[keyID] = newKey; } - addNextNormalKeyData(keyMapper, keyID, handSide, fingerType) { + addNextNormalKeyData(keyID, handSide, fingerType) { let prevKey = this.keyDataList[this.keyIndex - 1]; - let normalText = keyMapper.getNormalText(keyID); - let shiftText = keyMapper.getShiftText(keyID); + let normalText = this.keyMapper.getNormalText(keyID); + let shiftText = this.keyMapper.getShiftText(keyID); let newKey = this.makeNextNormalKeyDataObject( + keyID, prevKey, normalText, shiftText, handSide, fingerType @@ -129,7 +174,7 @@ class Keyboard { this.keyDataList[this.keyIndex] = newKey; this.keyIndex++; - this.keyHash[keyID] = newKey; + this.normalKeyHash[keyID] = newKey; } @@ -137,8 +182,7 @@ class Keyboard { initKeyData(keyMapper) { // row 1 this.addFunctionKeyData( - keyMapper, - "`", + "Backquote", KeyButton.LEFT_HAND, KeyButton.LITTLE_FINGER, Keyboard.KEYBOARD_OFFSET__POX_X, @@ -147,21 +191,20 @@ class Keyboard { Keyboard.DEFAULT_KEY_SIZE_PX, KeyButton.NORMAL_FUNCTION_KEY ); - this.addNextNormalKeyData(keyMapper, "1", KeyButton.LEFT_HAND, KeyButton.LITTLE_FINGER); - this.addNextNormalKeyData(keyMapper, "2", KeyButton.LEFT_HAND, KeyButton.RING_FINGER); - this.addNextNormalKeyData(keyMapper, "3", KeyButton.LEFT_HAND, KeyButton.MIDDLE_FINGER); - this.addNextNormalKeyData(keyMapper, "4", KeyButton.LEFT_HAND, KeyButton.INDEX_FINGER); - this.addNextNormalKeyData(keyMapper, "5", KeyButton.LEFT_HAND, KeyButton.INDEX_FINGER); - this.addNextNormalKeyData(keyMapper, "6", KeyButton.RIGHT_HAND, KeyButton.INDEX_FINGER); - this.addNextNormalKeyData(keyMapper, "7", KeyButton.RIGHT_HAND, KeyButton.INDEX_FINGER); - this.addNextNormalKeyData(keyMapper, "8", KeyButton.RIGHT_HAND, KeyButton.MIDDLE_FINGER); - this.addNextNormalKeyData(keyMapper, "9", KeyButton.RIGHT_HAND, KeyButton.RING_FINGER); - this.addNextNormalKeyData(keyMapper, "0", KeyButton.RIGHT_HAND, KeyButton.LITTLE_FINGER); - this.addNextNormalKeyData(keyMapper, "-", KeyButton.RIGHT_HAND, KeyButton.LITTLE_FINGER); - this.addNextNormalKeyData(keyMapper, "=", KeyButton.RIGHT_HAND, KeyButton.LITTLE_FINGER); + this.addNextNormalKeyData("Digit1", KeyButton.LEFT_HAND, KeyButton.LITTLE_FINGER); + this.addNextNormalKeyData("Digit2", KeyButton.LEFT_HAND, KeyButton.RING_FINGER); + this.addNextNormalKeyData("Digit3", KeyButton.LEFT_HAND, KeyButton.MIDDLE_FINGER); + this.addNextNormalKeyData("Digit4", KeyButton.LEFT_HAND, KeyButton.INDEX_FINGER); + this.addNextNormalKeyData("Digit5", KeyButton.LEFT_HAND, KeyButton.INDEX_FINGER); + this.addNextNormalKeyData("Digit6", KeyButton.RIGHT_HAND, KeyButton.INDEX_FINGER); + this.addNextNormalKeyData("Digit7", KeyButton.RIGHT_HAND, KeyButton.INDEX_FINGER); + this.addNextNormalKeyData("Digit8", KeyButton.RIGHT_HAND, KeyButton.MIDDLE_FINGER); + this.addNextNormalKeyData("Digit9", KeyButton.RIGHT_HAND, KeyButton.RING_FINGER); + this.addNextNormalKeyData("Digit0", KeyButton.RIGHT_HAND, KeyButton.LITTLE_FINGER); + this.addNextNormalKeyData("Minus", KeyButton.RIGHT_HAND, KeyButton.LITTLE_FINGER); + this.addNextNormalKeyData("Equal", KeyButton.RIGHT_HAND, KeyButton.LITTLE_FINGER); this.addNextFunctionKeyData( - keyMapper, - "backspace", + "Backspace", KeyButton.RIGHT_HAND, KeyButton.LITTLE_FINGER, Keyboard.BACKSPACE_KEY_WIDTH_PX, @@ -171,56 +214,53 @@ class Keyboard { // row 2 this.addFunctionKeyData( - keyMapper, - "tab", + "Tab", KeyButton.LEFT_HAND, - KeyButton.LITTLE_FINGER, + KeyButton.NONE_FINGER, Keyboard.KEYBOARD_OFFSET__POX_X, Keyboard.ROW_2_POX_Y, Keyboard.TAB_KEY_WIDTH_PX, Keyboard.DEFAULT_KEY_SIZE_PX, KeyButton.LEFT_FUNCTION_KEY ); - this.addNextNormalKeyData(keyMapper, "q", KeyButton.LEFT_HAND, KeyButton.LITTLE_FINGER); - this.addNextNormalKeyData(keyMapper, "w", KeyButton.LEFT_HAND, KeyButton.RING_FINGER); - this.addNextNormalKeyData(keyMapper, "e", KeyButton.LEFT_HAND, KeyButton.MIDDLE_FINGER); - this.addNextNormalKeyData(keyMapper, "r", KeyButton.LEFT_HAND, KeyButton.INDEX_FINGER); - this.addNextNormalKeyData(keyMapper, "t", KeyButton.LEFT_HAND, KeyButton.INDEX_FINGER); - this.addNextNormalKeyData(keyMapper, "y", KeyButton.RIGHT_HAND, KeyButton.INDEX_FINGER); - this.addNextNormalKeyData(keyMapper, "u", KeyButton.RIGHT_HAND, KeyButton.INDEX_FINGER); - this.addNextNormalKeyData(keyMapper, "i", KeyButton.RIGHT_HAND, KeyButton.MIDDLE_FINGER); - this.addNextNormalKeyData(keyMapper, "o", KeyButton.RIGHT_HAND, KeyButton.RING_FINGER); - this.addNextNormalKeyData(keyMapper, "p", KeyButton.RIGHT_HAND, KeyButton.LITTLE_FINGER); - this.addNextNormalKeyData(keyMapper, "[", KeyButton.RIGHT_HAND, KeyButton.LITTLE_FINGER); - this.addNextNormalKeyData(keyMapper, "]", KeyButton.RIGHT_HAND, KeyButton.LITTLE_FINGER); - this.addNextNormalKeyData(keyMapper, "\\", KeyButton.RIGHT_HAND, KeyButton.LITTLE_FINGER); + this.addNextNormalKeyData("KeyQ", KeyButton.LEFT_HAND, KeyButton.LITTLE_FINGER); + this.addNextNormalKeyData("KeyW", KeyButton.LEFT_HAND, KeyButton.RING_FINGER); + this.addNextNormalKeyData("KeyE", KeyButton.LEFT_HAND, KeyButton.MIDDLE_FINGER); + this.addNextNormalKeyData("KeyR", KeyButton.LEFT_HAND, KeyButton.INDEX_FINGER); + this.addNextNormalKeyData("KeyT", KeyButton.LEFT_HAND, KeyButton.INDEX_FINGER); + this.addNextNormalKeyData("KeyY", KeyButton.RIGHT_HAND, KeyButton.INDEX_FINGER); + this.addNextNormalKeyData("KeyU", KeyButton.RIGHT_HAND, KeyButton.INDEX_FINGER); + this.addNextNormalKeyData("KeyI", KeyButton.RIGHT_HAND, KeyButton.MIDDLE_FINGER); + this.addNextNormalKeyData("KeyO", KeyButton.RIGHT_HAND, KeyButton.RING_FINGER); + this.addNextNormalKeyData("KeyP", KeyButton.RIGHT_HAND, KeyButton.LITTLE_FINGER); + this.addNextNormalKeyData("BracketLeft", KeyButton.RIGHT_HAND, KeyButton.LITTLE_FINGER); + this.addNextNormalKeyData("BracketRight", KeyButton.RIGHT_HAND, KeyButton.LITTLE_FINGER); + this.addNextNormalKeyData("Backslash", KeyButton.RIGHT_HAND, KeyButton.LITTLE_FINGER); // row 3 this.addFunctionKeyData( - keyMapper, - "caps_lock", + "CapsLock", KeyButton.LEFT_HAND, - KeyButton.LITTLE_FINGER, + KeyButton.NONE_FINGER, Keyboard.KEYBOARD_OFFSET__POX_X, Keyboard.ROW_3_POX_Y, Keyboard.CAPS_LOCK_KEY_WIDTH_PX, Keyboard.DEFAULT_KEY_SIZE_PX, KeyButton.LEFT_FUNCTION_KEY ); - this.addNextNormalKeyData(keyMapper, "a", KeyButton.LEFT_HAND, KeyButton.LITTLE_FINGER); - this.addNextNormalKeyData(keyMapper, "s", KeyButton.LEFT_HAND, KeyButton.RING_FINGER); - this.addNextNormalKeyData(keyMapper, "d", KeyButton.LEFT_HAND, KeyButton.MIDDLE_FINGER); - this.addNextNormalKeyData(keyMapper, "f", KeyButton.LEFT_HAND, KeyButton.INDEX_FINGER); - this.addNextNormalKeyData(keyMapper, "g", KeyButton.LEFT_HAND, KeyButton.INDEX_FINGER); - this.addNextNormalKeyData(keyMapper, "h", KeyButton.RIGHT_HAND, KeyButton.INDEX_FINGER); - this.addNextNormalKeyData(keyMapper, "j", KeyButton.RIGHT_HAND, KeyButton.INDEX_FINGER); - this.addNextNormalKeyData(keyMapper, "k", KeyButton.RIGHT_HAND, KeyButton.MIDDLE_FINGER); - this.addNextNormalKeyData(keyMapper, "l", KeyButton.RIGHT_HAND, KeyButton.RING_FINGER); - this.addNextNormalKeyData(keyMapper, ";", KeyButton.RIGHT_HAND, KeyButton.LITTLE_FINGER); - this.addNextNormalKeyData(keyMapper, "'", KeyButton.RIGHT_HAND, KeyButton.LITTLE_FINGER); + this.addNextNormalKeyData("KeyA", KeyButton.LEFT_HAND, KeyButton.LITTLE_FINGER); + this.addNextNormalKeyData("KeyS", KeyButton.LEFT_HAND, KeyButton.RING_FINGER); + this.addNextNormalKeyData("KeyD", KeyButton.LEFT_HAND, KeyButton.MIDDLE_FINGER); + this.addNextNormalKeyData("KeyF", KeyButton.LEFT_HAND, KeyButton.INDEX_FINGER_BASELINE); + this.addNextNormalKeyData("KeyG", KeyButton.LEFT_HAND, KeyButton.INDEX_FINGER); + this.addNextNormalKeyData("KeyH", KeyButton.RIGHT_HAND, KeyButton.INDEX_FINGER); + this.addNextNormalKeyData("KeyJ", KeyButton.RIGHT_HAND, KeyButton.INDEX_FINGER_BASELINE); + this.addNextNormalKeyData("KeyK", KeyButton.RIGHT_HAND, KeyButton.MIDDLE_FINGER); + this.addNextNormalKeyData("KeyL", KeyButton.RIGHT_HAND, KeyButton.RING_FINGER); + this.addNextNormalKeyData("Semicolon", KeyButton.RIGHT_HAND, KeyButton.LITTLE_FINGER); + this.addNextNormalKeyData("Quote", KeyButton.RIGHT_HAND, KeyButton.LITTLE_FINGER); this.addNextFunctionKeyData( - keyMapper, - "enter", + "Enter", KeyButton.RIGHT_HAND, KeyButton.LITTLE_FINGER, Keyboard.ENTER_KEY_WIDTH_PX, @@ -230,8 +270,7 @@ class Keyboard { // row 4 this.addFunctionKeyData( - keyMapper, - "left_shift", + "ShiftLeft", KeyButton.LEFT_HAND, KeyButton.LITTLE_FINGER, Keyboard.KEYBOARD_OFFSET__POX_X, @@ -240,19 +279,18 @@ class Keyboard { Keyboard.DEFAULT_KEY_SIZE_PX, KeyButton.LEFT_FUNCTION_KEY ); - this.addNextNormalKeyData(keyMapper, "z", KeyButton.LEFT_HAND, KeyButton.LITTLE_FINGER); - this.addNextNormalKeyData(keyMapper, "x", KeyButton.LEFT_HAND, KeyButton.RING_FINGER); - this.addNextNormalKeyData(keyMapper, "c", KeyButton.LEFT_HAND, KeyButton.MIDDLE_FINGER); - this.addNextNormalKeyData(keyMapper, "v", KeyButton.LEFT_HAND, KeyButton.INDEX_FINGER); - this.addNextNormalKeyData(keyMapper, "b", KeyButton.LEFT_HAND, KeyButton.INDEX_FINGER); - this.addNextNormalKeyData(keyMapper, "n", KeyButton.RIGHT_HAND, KeyButton.INDEX_FINGER); - this.addNextNormalKeyData(keyMapper, "m", KeyButton.RIGHT_HAND, KeyButton.INDEX_FINGER); - this.addNextNormalKeyData(keyMapper, ",", KeyButton.RIGHT_HAND, KeyButton.MIDDLE_FINGER); - this.addNextNormalKeyData(keyMapper, ".", KeyButton.RIGHT_HAND, KeyButton.RING_FINGER); - this.addNextNormalKeyData(keyMapper, "/", KeyButton.RIGHT_HAND, KeyButton.LITTLE_FINGER); + this.addNextNormalKeyData("KeyZ", KeyButton.LEFT_HAND, KeyButton.LITTLE_FINGER); + this.addNextNormalKeyData("KeyX", KeyButton.LEFT_HAND, KeyButton.RING_FINGER); + this.addNextNormalKeyData("KeyC", KeyButton.LEFT_HAND, KeyButton.MIDDLE_FINGER); + this.addNextNormalKeyData("KeyV", KeyButton.LEFT_HAND, KeyButton.INDEX_FINGER); + this.addNextNormalKeyData("KeyB", KeyButton.LEFT_HAND, KeyButton.INDEX_FINGER); + this.addNextNormalKeyData("KeyN", KeyButton.RIGHT_HAND, KeyButton.INDEX_FINGER); + this.addNextNormalKeyData("KeyM", KeyButton.RIGHT_HAND, KeyButton.INDEX_FINGER); + this.addNextNormalKeyData("Comma", KeyButton.RIGHT_HAND, KeyButton.MIDDLE_FINGER); + this.addNextNormalKeyData("Period", KeyButton.RIGHT_HAND, KeyButton.RING_FINGER); + this.addNextNormalKeyData("Slash", KeyButton.RIGHT_HAND, KeyButton.LITTLE_FINGER); this.addNextFunctionKeyData( - keyMapper, - "right_shift", + "ShiftRight", KeyButton.RIGHT_HAND, KeyButton.LITTLE_FINGER, Keyboard.SHIFT_KEY_WIDTH_PX, @@ -262,10 +300,9 @@ class Keyboard { // row 5 this.addFunctionKeyData( - keyMapper, - "left_ctrl", + "ControlLeft", KeyButton.LEFT_HAND, - KeyButton.LITTLE_FINGER, + KeyButton.NONE_FINGER, Keyboard.KEYBOARD_OFFSET__POX_X, Keyboard.ROW_5_POX_Y, Keyboard.CTRL_KEY_WIDTH_PX, @@ -273,35 +310,31 @@ class Keyboard { KeyButton.LEFT_FUNCTION_KEY ); this.addNextFunctionKeyData( - keyMapper, "window", KeyButton.LEFT_HAND, - KeyButton.LITTLE_FINGER, + KeyButton.NONE_FINGER, Keyboard.WINDOW_KEY_WIDTH_PX, Keyboard.DEFAULT_KEY_SIZE_PX, KeyButton.LEFT_FUNCTION_KEY ); this.addNextFunctionKeyData( - keyMapper, - "left_alt", + "AltLeft", KeyButton.LEFT_HAND, - KeyButton.LITTLE_FINGER, + KeyButton.NONE_FINGER, Keyboard.ALT_KEY_WIDTH_PX, Keyboard.DEFAULT_KEY_SIZE_PX, KeyButton.LEFT_FUNCTION_KEY ); this.addNextFunctionKeyData( - keyMapper, "chinese", KeyButton.LEFT_HAND, - KeyButton.LITTLE_FINGER, + KeyButton.NONE_FINGER, Keyboard.CHINESE_KEY_WIDTH_PX, Keyboard.DEFAULT_KEY_SIZE_PX, KeyButton.LEFT_FUNCTION_KEY ); this.addNextFunctionKeyData( - keyMapper, - "space", + "Space", KeyButton.BOTH_HAND, KeyButton.THUMB, Keyboard.SPACE_KEY_WIDTH_PX, @@ -309,28 +342,25 @@ class Keyboard { KeyButton.CENTER_FUNCTION_KEY ); this.addNextFunctionKeyData( - keyMapper, "korean_english", KeyButton.RIGHT_HAND, - KeyButton.LITTLE_FINGER, + KeyButton.NONE_FINGER, Keyboard.KOREAN_ENGLISH_KEY_WIDTH_PX, Keyboard.DEFAULT_KEY_SIZE_PX, KeyButton.RIGHT_FUNCTION_KEY ); this.addNextFunctionKeyData( - keyMapper, - "right_alt", + "AltRight", KeyButton.RIGHT_HAND, - KeyButton.LITTLE_FINGER, + KeyButton.NONE_FINGER, Keyboard.ALT_KEY_WIDTH_PX, Keyboard.DEFAULT_KEY_SIZE_PX, KeyButton.RIGHT_FUNCTION_KEY ); this.addNextFunctionKeyData( - keyMapper, - "right_ctrl", + "ControlRight", KeyButton.RIGHT_HAND, - KeyButton.LITTLE_FINGER, + KeyButton.NONE_FINGER, Keyboard.CTRL_KEY_WIDTH_PX, Keyboard.DEFAULT_KEY_SIZE_PX, KeyButton.RIGHT_FUNCTION_KEY diff --git a/src/game/typing/practice/korean_key_mapper.js b/src/game/typing/practice/korean_key_mapper.js index 7e92bf1..d0d50e4 100644 --- a/src/game/typing/practice/korean_key_mapper.js +++ b/src/game/typing/practice/korean_key_mapper.js @@ -3,34 +3,34 @@ class KoreanKeyMapper extends KeyMapper { constructor() { super(); - this.registerKeyTextData("q", "ㅂ", "ㅃ", KeyTextData.RIGHT_HAND); - this.registerKeyTextData("w", "ㅈ", "ㅉ", KeyTextData.RIGHT_HAND); - this.registerKeyTextData("e", "ㄷ", "ㄸ", KeyTextData.RIGHT_HAND); - this.registerKeyTextData("r", "ㄱ", "ㄲ", KeyTextData.RIGHT_HAND); - this.registerKeyTextData("t", "ㅅ", "ㅆ", KeyTextData.RIGHT_HAND); - this.registerKeyTextData("y", "ㅛ", "ㅛ", KeyTextData.LEFT_HAND); - this.registerKeyTextData("u", "ㅕ", "ㅕ", KeyTextData.LEFT_HAND); - this.registerKeyTextData("i", "ㅑ", "ㅑ", KeyTextData.LEFT_HAND); - this.registerKeyTextData("o", "ㅐ", "ㅒ", KeyTextData.LEFT_HAND); - this.registerKeyTextData("p", "ㅔ", "ㅖ", KeyTextData.LEFT_HAND); + this.registerKeyTextData("KeyQ", "ㅂ", "ㅃ"); + this.registerKeyTextData("KeyR", "ㅈ", "ㅉ"); + this.registerKeyTextData("KeyEe", "ㄷ", "ㄸ"); + this.registerKeyTextData("KeyR", "ㄱ", "ㄲ"); + this.registerKeyTextData("KeyT", "ㅅ", "ㅆ"); + this.registerKeyTextData("KeyY", "ㅛ", "ㅛ"); + this.registerKeyTextData("KeyU", "ㅕ", "ㅕ"); + this.registerKeyTextData("KeyI", "ㅑ", "ㅑ"); + this.registerKeyTextData("KeyO", "ㅐ", "ㅒ"); + this.registerKeyTextData("KeyP", "ㅔ", "ㅖ"); - this.registerKeyTextData("a", "ㅁ", "ㅁ", KeyTextData.RIGHT_HAND); - this.registerKeyTextData("s", "ㄴ", "ㄴ", KeyTextData.RIGHT_HAND); - this.registerKeyTextData("d", "ㅇ", "ㅇ", KeyTextData.RIGHT_HAND); - this.registerKeyTextData("f", "ㄹ", "ㄹ", KeyTextData.RIGHT_HAND); - this.registerKeyTextData("g", "ㅎ", "ㅎ", KeyTextData.RIGHT_HAND); - this.registerKeyTextData("h", "ㅗ", "ㅗ", KeyTextData.LEFT_HAND); - this.registerKeyTextData("j", "ㅓ", "ㅓ", KeyTextData.LEFT_HAND); - this.registerKeyTextData("k", "ㅏ", "ㅏ", KeyTextData.LEFT_HAND); - this.registerKeyTextData("l", "ㅣ", "ㅣ", KeyTextData.LEFT_HAND); + this.registerKeyTextData("KeyA", "ㅁ", "ㅁ"); + this.registerKeyTextData("KeyS", "ㄴ", "ㄴ"); + this.registerKeyTextData("KeyD", "ㅇ", "ㅇ"); + this.registerKeyTextData("KeyF", "ㄹ", "ㄹ"); + this.registerKeyTextData("KeyG”", "ㅎ", "ㅎ"); + this.registerKeyTextData("KeyH", "ㅗ", "ㅗ"); + this.registerKeyTextData("KeyJ", "ㅓ", "ㅓ"); + this.registerKeyTextData("KeyJ", "ㅏ", "ㅏ"); + this.registerKeyTextData("KeyL", "ㅣ", "ㅣ"); - this.registerKeyTextData("z", "ㅋ", "ㅋ", KeyTextData.RIGHT_HAND); - this.registerKeyTextData("x", "ㅌ", "ㅌ", KeyTextData.RIGHT_HAND); - this.registerKeyTextData("c", "ㅊ", "ㅊ", KeyTextData.RIGHT_HAND); - this.registerKeyTextData("v", "ㅍ", "ㅍ", KeyTextData.RIGHT_HAND); - this.registerKeyTextData("b", "ㅠ", "ㅠ", KeyTextData.RIGHT_HAND); - this.registerKeyTextData("n", "ㅜ", "ㅜ", KeyTextData.LEFT_HAND); - this.registerKeyTextData("m", "ㅡ", "ㅡ", KeyTextData.LEFT_HAND); + this.registerKeyTextData("KeyZ", "ㅋ", "ㅋ"); + this.registerKeyTextData("KeyX", "ㅌ", "ㅌ"); + this.registerKeyTextData("KeyC", "ㅊ", "ㅊ"); + this.registerKeyTextData("KeyV", "ㅍ", "ㅍ"); + this.registerKeyTextData("KeyB", "ㅠ", "ㅠ"); + this.registerKeyTextData("KeyN", "ㅜ", "ㅜ"); + this.registerKeyTextData("KeyM", "ㅡ", "ㅡ"); } } \ No newline at end of file diff --git a/test/key_mapper.js b/test/key_mapper.js index 8c634e0..07f454d 100644 --- a/test/key_mapper.js +++ b/test/key_mapper.js @@ -4,56 +4,58 @@ let koreanKeyMapper = new KoreanKeyMapper(); QUnit.test( "getNormalText", function( assert ) { - assert.equal(englishKeyMapper.getNormalText("`"), "`", "getNormalText - `"); - assert.equal(englishKeyMapper.getNormalText("/"), "/", "getNormalText - /"); + assert.equal(englishKeyMapper.getNormalText("Backquote"), "`", "getNormalText - `"); + assert.equal(englishKeyMapper.getNormalText("Slash"), "/", "getNormalText - /"); - assert.equal(englishKeyMapper.getNormalText("q"), "q", "getNormalText - q"); - assert.equal(englishKeyMapper.getNormalText("m"), "m", "getNormalText - m"); + assert.equal(englishKeyMapper.getNormalText("KeyQ"), "q", "getNormalText - q"); + assert.equal(englishKeyMapper.getNormalText("KeyM"), "m", "getNormalText - m"); - assert.equal(koreanKeyMapper.getNormalText("q"), "ㅂ", "getNormalText - ㅂ"); - assert.equal(koreanKeyMapper.getNormalText("m"), "ㅡ", "getNormalText - ㅡ"); + assert.equal(koreanKeyMapper.getNormalText("KeyQ"), "ㅂ", "getNormalText - ㅂ"); + assert.equal(koreanKeyMapper.getNormalText("KeyM"), "ㅡ", "getNormalText - ㅡ"); }); QUnit.test( "getShiftText", function( assert ) { - assert.equal(englishKeyMapper.getShiftText("`"), "~", "getShiftText - ~"); - assert.equal(englishKeyMapper.getShiftText("/"), "?", "getShiftText - ?"); + assert.equal(englishKeyMapper.getShiftText("Backquote"), "~", "getShiftText - ~"); + assert.equal(englishKeyMapper.getShiftText("Slash"), "?", "getShiftText - ?"); - assert.equal(englishKeyMapper.getShiftText("q"), "Q", "getShiftText - Q"); - assert.equal(englishKeyMapper.getShiftText("m"), "M", "getShiftText - M"); + assert.equal(englishKeyMapper.getShiftText("KeyQ"), "Q", "getShiftText - Q"); + assert.equal(englishKeyMapper.getShiftText("KeyM"), "M", "getShiftText - M"); - assert.equal(koreanKeyMapper.getShiftText("q"), "ㅃ", "getShiftText - ㅃ"); - assert.equal(koreanKeyMapper.getShiftText("m"), "ㅡ", "getShiftText - ㅡ"); + assert.equal(koreanKeyMapper.getShiftText("KeyQ"), "ㅃ", "getShiftText - ㅃ"); + assert.equal(koreanKeyMapper.getShiftText("KeyM"), "ㅡ", "getShiftText - ㅡ"); }); QUnit.test( "getShiftHandSide", function( assert ) { - assert.equal(englishKeyMapper.getShiftHandSide("`"), KeyTextData.RIGHT_HAND, "getShiftHandSide - `"); - assert.equal(englishKeyMapper.getShiftHandSide("/"), KeyTextData.LEFT_HAND, "getShiftHandSide - /"); + assert.equal(englishKeyMapper.getShiftHandSide("Backquote"), KeyTextData.RIGHT_HAND, "getShiftHandSide - `"); + assert.equal(englishKeyMapper.getShiftHandSide("Slash"), KeyTextData.LEFT_HAND, "getShiftHandSide - /"); - assert.equal(englishKeyMapper.getShiftHandSide("space"), KeyTextData.BOTH_HAND, "getShiftHandSide - space"); + assert.equal(englishKeyMapper.getShiftHandSide("Space"), KeyTextData.BOTH_HAND, "getShiftHandSide - space"); - assert.equal(englishKeyMapper.getShiftHandSide("q"), KeyTextData.RIGHT_HAND, "getShiftHandSide - q"); - assert.equal(englishKeyMapper.getShiftHandSide("m"), KeyTextData.LEFT_HAND, "getShiftHandSide - m"); + assert.equal(englishKeyMapper.getShiftHandSide("KeyQ"), KeyTextData.RIGHT_HAND, "getShiftHandSide - q"); + assert.equal(englishKeyMapper.getShiftHandSide("KeyM"), KeyTextData.LEFT_HAND, "getShiftHandSide - m"); - assert.equal(koreanKeyMapper.getShiftHandSide("q"), KeyTextData.RIGHT_HAND, "getShiftHandSide - q"); - assert.equal(koreanKeyMapper.getShiftHandSide("m"), KeyTextData.LEFT_HAND, "getShiftHandSide - m"); + assert.equal(koreanKeyMapper.getShiftHandSide("KeyQ"), KeyTextData.RIGHT_HAND, "getShiftHandSide - q"); + assert.equal(koreanKeyMapper.getShiftHandSide("KeyM"), KeyTextData.LEFT_HAND, "getShiftHandSide - m"); }); QUnit.test( "getKeyIDOfText", function( assert ) { - assert.equal(englishKeyMapper.getKeyIDOfText("`"), "`", "getKeyIDOfText - `"); - assert.equal(englishKeyMapper.getKeyIDOfText("~"), "`", "getKeyIDOfText - ~"); - assert.equal(englishKeyMapper.getKeyIDOfText("/"), "/", "getKeyIDOfText - /"); - assert.equal(englishKeyMapper.getKeyIDOfText("?"), "/", "getKeyIDOfText - ?"); + assert.equal(englishKeyMapper.getKeyIDOfText("`"), "Backquote", "getKeyIDOfText - `"); + assert.equal(englishKeyMapper.getKeyIDOfText("~"), "Backquote", "getKeyIDOfText - ~"); + assert.equal(englishKeyMapper.getKeyIDOfText("/"), "Slash", "getKeyIDOfText - /"); + assert.equal(englishKeyMapper.getKeyIDOfText("?"), "Slash", "getKeyIDOfText - ?"); - assert.equal(englishKeyMapper.getKeyIDOfText("q"), "q", "getKeyIDOfText - q"); - assert.equal(englishKeyMapper.getKeyIDOfText("Q"), "q", "getKeyIDOfText - Q"); - assert.equal(englishKeyMapper.getKeyIDOfText("m"), "m", "getKeyIDOfText - m"); - assert.equal(englishKeyMapper.getKeyIDOfText("M"), "m", "getKeyIDOfText - M"); + assert.equal(englishKeyMapper.getKeyIDOfText("q"), "KeyQ", "getKeyIDOfText - q"); + assert.equal(englishKeyMapper.getKeyIDOfText("Q"), "KeyQ", "getKeyIDOfText - Q"); + assert.equal(englishKeyMapper.getKeyIDOfText("m"), "KeyM", "getKeyIDOfText - m"); + assert.equal(englishKeyMapper.getKeyIDOfText("M"), "KeyM", "getKeyIDOfText - M"); - assert.equal(koreanKeyMapper.getKeyIDOfText("ㅂ"), "q", "getKeyIDOfText - ㅂ"); - assert.equal(koreanKeyMapper.getKeyIDOfText("ㅃ"), "q", "getKeyIDOfText - ㅃ"); - assert.equal(koreanKeyMapper.getKeyIDOfText("ㅡ"), "m", "getKeyIDOfText - ㅡ"); + assert.equal(koreanKeyMapper.getKeyIDOfText("ㅂ"), "KeyQ", "getKeyIDOfText - ㅂ"); + assert.equal(koreanKeyMapper.getKeyIDOfText("ㅃ"), "KeyQ", "getKeyIDOfText - ㅃ"); + assert.equal(koreanKeyMapper.getKeyIDOfText("ㅡ"), "KeyM", "getKeyIDOfText - ㅡ"); + + assert.equal(koreanKeyMapper.getKeyIDOfText("Backspace"), "Backspace", "getKeyIDOfText - ㅂ"); }); QUnit.test( "getShiftTypeOfText", function( assert ) {