cloud-game/web/js/gesture_keyboard.js
Sadlil Rhythom 0e17092acb Refactor of cloud game overlord and overworker (#70)
* Introduce Makefile and go vendor directory for faster build

* WIP: Refactor cloud-game codebase with spliting overlord and worker binary

* Fix all issues and have a running build

* Complete first version of refactor
2019-09-12 03:35:21 +08:00

38 lines
675 B
JavaScript
Vendored

/*
Keyboard gesture
*/
const KEYBOARD_MAP = {
37: "left",
38: "up",
39: "right",
40: "down",
90: "a", // z
88: "b", // x
67: "x", // c
86: "y", // v
13: "start", // start
16: "select", // select
// non-game
81: "quit", // q
83: "save", // s
87: "join", // w
65: "load", // a
70: "full", // f
72: "help", // h
}
$("body").on("keyup", function (event) {
if (event.keyCode in KEYBOARD_MAP) {
doButtonUp(KEYBOARD_MAP[event.keyCode]);
}
});
$("body").on("keydown", function (event) {
if (event.keyCode in KEYBOARD_MAP) {
doButtonDown(KEYBOARD_MAP[event.keyCode]);
}
});