Fixes for keydown events

This commit is contained in:
Neale Pickett 2013-11-02 14:35:21 -06:00
parent 562ae7042f
commit 45845ab9ee
1 changed files with 364 additions and 337 deletions

View File

@ -357,21 +357,48 @@ function handle(event) {
function key(event) {
var e = event || window.event;
var k = e.which || e.keyCode || 0;
var c;
var newstate;
switch (e.keyCode) {
switch (k) {
case 32:
c = " ";
break;
case 38:
c = "up";
break;
case 40:
c = "down";
break;
case 188:
c = ",";
break;
case 190:
c = ".";
break;
case 221:
c = e.shiftKey ? "}" : "]";
break;
case 219:
c = e.shiftKey ? "{" : "[";
break;
default:
c = String.fromCharCode(e.which || e.keyCode || 0);
if ((k >= 48) && (k <= 90)) {
c = String.fromCharCode(k);
if (! e.shiftKey) {
c = c.toLowerCase();
}
} else {
c = null;
}
break;
}
bige = e;
console.log("Key " + k + " pressed: " + c + " === " + e.which);
switch (c) {
case "up":
if ((state == TIMEOUT) || (state == SETUP)) {
@ -439,7 +466,7 @@ function key(event) {
function save() {
chrome.storage.sync.set(
chrome.storage.local.set(
{
"period_clock": e("period").remaining(),
"name_a": e("name-a").innerHTML,
@ -505,7 +532,7 @@ function start() {
startTimer(p);
p.set(c);
}
chrome.storage.sync.get(null, load);
chrome.storage.local.get(null, load);
ei("jammer-a");
ei("jammer-b");
@ -519,7 +546,7 @@ function start() {
startTimer(j, window.tenths);
j.set(120000);
save_timer = setInterval(save, 1000);
save_timer = setInterval(save, 10000); // Every 10 seconds
update_itimer = setInterval(update, 33);
}