{"id":24520998,"url":"https://github.com/pfirpfel/node-exclusive-keyboard","last_synced_at":"2025-08-09T03:19:56.609Z","repository":{"id":52681769,"uuid":"198292209","full_name":"pfirpfel/node-exclusive-keyboard","owner":"pfirpfel","description":"Keylogger for NodeJS and Linux that grabs the input device exclusively using ioctl EVIOCGRAB.","archived":false,"fork":false,"pushed_at":"2023-01-03T08:02:34.000Z","size":14,"stargazers_count":12,"open_issues_count":1,"forks_count":5,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-02T05:52:49.329Z","etag":null,"topics":["eviocgrab","ioctl","keyboard","keylogger","linux-devices","nodejs"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pfirpfel.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-07-22T19:49:58.000Z","updated_at":"2024-10-04T01:21:52.000Z","dependencies_parsed_at":"2023-02-01T05:30:43.179Z","dependency_job_id":null,"html_url":"https://github.com/pfirpfel/node-exclusive-keyboard","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pfirpfel%2Fnode-exclusive-keyboard","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pfirpfel%2Fnode-exclusive-keyboard/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pfirpfel%2Fnode-exclusive-keyboard/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pfirpfel%2Fnode-exclusive-keyboard/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pfirpfel","download_url":"https://codeload.github.com/pfirpfel/node-exclusive-keyboard/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":235053762,"owners_count":18928440,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["eviocgrab","ioctl","keyboard","keylogger","linux-devices","nodejs"],"created_at":"2025-01-22T02:48:42.711Z","updated_at":"2025-01-22T02:48:43.493Z","avatar_url":"https://github.com/pfirpfel.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# node-exclusive-keyboard\nKeylogger for NodeJS and Linux that grabs the input device exclusively.\n\nUseful for capturing USB input devices that act like keyboards, so that their inputs do no pollute other processes like terminals.\n\nBased on [node-keylogger](https://github.com/taosx/node-keylogger/) and [node-ioctl](https://github.com/santigimeno/node-ioctl).\n\n## Installation\n```bash\nnpm install --save exclusive-keyboard\n```\n\n## Usage\n\nSet access control right to device for user `username`:\n```bash\nsudo setfacl -m u:username:r /dev/input/by-id/usb-Logitech_Logitech_USB_Keyboard-event-kbd\n```\n\n```js\nconst ExclusiveKeyboard = require('exclusive-keyboard');\n\nconst keyboard = new ExclusiveKeyboard('by-id/usb-Logitech_Logitech_USB_Keyboard-event-kbd', true);\nkeyboard.on('keyup', console.log);\nkeyboard.on('keydown', console.log);\nkeyboard.on('keypress', console.log);\nkeyboard.on('close', console.log);\nkeyboard.on('error', console.error);\n```\n\n## API\n\n### `new ExclusiveKeyboard(dev, exclusive)`\n* `dev` (string): Device name (part after '/dev/input/'). Example: 'event0' would use '/dev/input/event0'\n* `exclusive` (boolean): If true, grab device exclusively using ioctl EVIOCGRAB (default: true)\n\n### `close()`\nReleases the grabbed device and closes the file descriptor. Emits 'close' event when done.\n\n### ExclusiveKeyboard.Keys\nMapping of key codes to key ids, see `keycodes.js`.\n\n### Event `keyup(event)`\nExample event:\n```js\n{\n  timeS: 39234,\n  timeMS: 3812,\n  keyCode: 71,\n  keyId: 'KEY_KP7',\n  type: 'keyup',\n  dev: 'by-id/usb-SEM_Trust_Numpad-event-kbd'\n}\n```\n\n### Event `keypress(event)`\nExample event:\n```js\n{\n  timeS: 39234,\n  timeMS: 3812,\n  keyCode: 71,\n  keyId: 'KEY_KP7',\n  type: 'keypress',\n  dev: 'by-id/usb-SEM_Trust_Numpad-event-kbd'\n}\n```\n\n### Event `keydown(event)`\n```js\n{\n  timeS: 39234,\n  timeMS: 3812,\n  keyCode: 71,\n  keyId: 'KEY_KP7',\n  type: 'keydown',\n  dev: 'by-id/usb-SEM_Trust_Numpad-event-kbd'\n}\n```\n\n### Event `error(error)`\n\n### Event `close()`\n\n## Contributors\nThank you to the following contributors:\n\n* [Janek Thomaschewski](https://github.com/jthomaschewski)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpfirpfel%2Fnode-exclusive-keyboard","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpfirpfel%2Fnode-exclusive-keyboard","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpfirpfel%2Fnode-exclusive-keyboard/lists"}