@hscmap/keybind
Advanced tools
Comparing version 0.0.1 to 0.0.2
@@ -22,3 +22,5 @@ "use strict"; | ||
var key = keys[0]; | ||
this.key = key.length == 1 ? this.key = "Key" + key.toUpperCase() : key; | ||
if (key.length != 1) | ||
throw new Error("invalid keybind source: " + source); | ||
this.key = keyCode2code(key.charCodeAt(0)); | ||
} | ||
@@ -33,3 +35,3 @@ KeyCombination.prototype.match = function (e) { | ||
KeyCombination.prototype.html = function () { | ||
var m = this.key.match(/^Key([A-Z])$/); | ||
var m = this.key.match(/^Key([A-Z1-9])$/); | ||
var key = m ? m[1] : this.key; | ||
@@ -47,6 +49,10 @@ return [ | ||
function whichKey(e) { | ||
if (e.code) | ||
return e.code; | ||
return "Key" + String.fromCharCode(e.keyCode); | ||
// if (e.code) | ||
// return e.code | ||
return keyCode2code(e.keyCode); | ||
} | ||
function keyCode2code(keyCode) { | ||
var key = String.fromCharCode(keyCode); | ||
return "Key" + key; | ||
} | ||
var Keybind = /** @class */ (function () { | ||
@@ -53,0 +59,0 @@ function Keybind(kc, handler) { |
{ | ||
"name": "@hscmap/keybind", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"main": "./lib/index.js", | ||
@@ -5,0 +5,0 @@ "types": "./lib/index.d.ts", |
4342
4
89