From 620874482801b4e43efefcd4f0aefa787a48f5f2 Mon Sep 17 00:00:00 2001 From: Devine Lu Linvega Date: Fri, 11 Nov 2016 19:44:23 -0800 Subject: [PATCH] Added keyboard.js --- index.html | 1 + scripts/keyboard.js | 54 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+) create mode 100644 scripts/keyboard.js diff --git a/index.html b/index.html index 1424a23..ae12102 100644 --- a/index.html +++ b/index.html @@ -4,6 +4,7 @@ + diff --git a/scripts/keyboard.js b/scripts/keyboard.js new file mode 100644 index 0000000..aa6d433 --- /dev/null +++ b/scripts/keyboard.js @@ -0,0 +1,54 @@ +function Keyboard() +{ + this.is_locked = false; + + this.lock = function() + { + this.is_locked = true; + interface.actions_panel.style.color = "red"; + } + + this.unlock = function() + { + this.is_locked = false; + interface.actions_panel.style.color = "black"; + } + + this.listen = function(event) + { + if(this.is_locked === true){ return; } + switch (event.keyCode) + { + case 13: this.key_enter(); break; + case 32: this.key_space(); break; + case 38: this.key_arrow_up(); break; + case 40: this.key_arrow_down(); break; + case 37: this.key_arrow_left(); break; + case 39: this.key_arrow_right(); break; + } + }; + + this.key_enter = function() + { + } + + this.key_space = function() + { + } + + this.key_arrow_up = function() + { + } + + this.key_arrow_down = function() + { + } + + this.key_arrow_left = function() + { + } + + this.key_arrow_right = function() + { + } +} \ No newline at end of file