@hscmap/keybind
Advanced tools
Comparing version 0.0.4 to 0.0.5
@@ -22,7 +22,6 @@ "use strict"; | ||
var key = keys[0]; | ||
if (key.length != 1) | ||
throw new Error("invalid keybind source: " + source); | ||
this.key = keyCode2code(key.charCodeAt(0)); | ||
this.key = key.length == 1 ? key.toLowerCase() : key; | ||
} | ||
KeyCombination.prototype.match = function (e) { | ||
var key = e.key.length == 1 ? e.key.toLowerCase() : e.key; | ||
return (e.altKey == this.alt && | ||
@@ -32,7 +31,6 @@ e.shiftKey == this.shift && | ||
e.metaKey == this.meta && | ||
whichKey(e) == this.key); | ||
key == this.key); | ||
}; | ||
KeyCombination.prototype.html = function () { | ||
var m = this.key.match(/^Key([A-Z1-9])$/); | ||
var key = m ? m[1] : this.key; | ||
var key = this.key.length == 1 ? this.key.toUpperCase() : this.key; | ||
return [ | ||
@@ -48,11 +46,2 @@ this.alt ? '⌥' : '', | ||
}()); | ||
function whichKey(e) { | ||
// if (e.code) | ||
// return e.code | ||
return keyCode2code(e.keyCode); | ||
} | ||
function keyCode2code(keyCode) { | ||
var key = String.fromCharCode(keyCode).toUpperCase(); | ||
return "Key" + key; | ||
} | ||
var Keybind = /** @class */ (function () { | ||
@@ -82,3 +71,3 @@ function Keybind(kc, handler) { | ||
var i = keybinds.indexOf(kb); | ||
console.assert(i >= 0); | ||
console.assert(i >= 0, "keybind " + source + " is not registered"); | ||
keybinds.splice(i, 1); | ||
@@ -85,0 +74,0 @@ }; |
{ | ||
"name": "@hscmap/keybind", | ||
"version": "0.0.4", | ||
"version": "0.0.5", | ||
"main": "./lib/index.js", | ||
@@ -12,10 +12,10 @@ "types": "./lib/index.d.ts", | ||
"devDependencies": { | ||
"file-loader": "^1.1.10", | ||
"gh-pages": "^1.1.0", | ||
"ts-loader": "^4.0.0", | ||
"ts-node": "^5.0.0", | ||
"typescript": "^2.7.2", | ||
"webpack": "^4.0.1", | ||
"webpack-cli": "^2.0.9", | ||
"webpack-dev-server": "^3.1.0" | ||
"file-loader": "^1.1.11", | ||
"gh-pages": "^1.2.0", | ||
"ts-loader": "^4.4.2", | ||
"ts-node": "^7.0.0", | ||
"typescript": "^2.9.2", | ||
"webpack": "^4.16.0", | ||
"webpack-cli": "^3.0.8", | ||
"webpack-dev-server": "^3.1.4" | ||
}, | ||
@@ -22,0 +22,0 @@ "homepage": "https://github.com/michitaro/keybind", |
4203
78