browser-forward-keyboard-listener
Advanced tools
Comparing version
@@ -35,2 +35,3 @@ // Create WebSocket connection. | ||
const handleKeyDown = (key) => { | ||
// prevent this event to keep firing when the key is held down | ||
if (activeKeys.has(key)) | ||
@@ -53,15 +54,15 @@ return; | ||
e.preventDefault(); | ||
handleKeyDown(e.key.toLowerCase()); | ||
handleKeyDown(e.code); | ||
}); | ||
document.addEventListener('keyup', function (e) { | ||
e.preventDefault(); | ||
handleKeyUp(e.key.toLowerCase()); | ||
handleKeyUp(e.code); | ||
}); | ||
document.addEventListener('mousedown', function (e) { | ||
e.preventDefault(); | ||
handleKeyDown("mouse" + e.button); | ||
handleKeyDown("Mouse" + e.button); | ||
}); | ||
document.addEventListener('mouseup', function (e) { | ||
e.preventDefault(); | ||
handleKeyUp("mouse" + e.button); | ||
handleKeyUp("Mouse" + e.button); | ||
}); | ||
@@ -68,0 +69,0 @@ document.addEventListener('contextmenu', (e) => e.preventDefault()); |
export * from "./KeyListenersManager"; | ||
export * from "./keys"; | ||
export declare function initKeyboardListener(): void; |
@@ -9,2 +9,4 @@ "use strict"; | ||
__export(require("./KeyListenersManager")); | ||
__export(require("./keys")); | ||
// open the browser and start listening to user input | ||
function initKeyboardListener() { | ||
@@ -11,0 +13,0 @@ const port = process.env.PORT || 3000; |
{ | ||
"name": "browser-forward-keyboard-listener", | ||
"description": "capture mouse and keyboard event from browser and send them back via WS", | ||
"version": "1.1.0", | ||
"version": "1.1.1", | ||
"private": false, | ||
@@ -9,2 +9,3 @@ "main": "dist/index.js", | ||
"scripts": { | ||
"build": "tsc", | ||
"tsc": "tsc" | ||
@@ -11,0 +12,0 @@ }, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
65619
19.92%44
7.32%800
36.52%