simen-keyboard-listener 1.0.3 → 1.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -21
- package/README.md +69 -69
- package/package.json +58 -58
- package/src/native/binding.gyp +40 -40
- package/src/native/package.json +14 -14
- package/src/native/prebuilds/win32-x64/simen-keyboard-listener-native.node +0 -0
- package/src/native/simen_keyboard_listener.cc +627 -627
- package/prebuilds/darwin-arm64/simen_keyboard_listener.node +0 -0
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2024 Simen
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Simen
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,69 +1,69 @@
|
|
|
1
|
-
# simen-keyboard-listener
|
|
2
|
-
|
|
3
|
-
Native global keyboard listener for macOS and Windows. Captures keyboard events system-wide, including special keys like FN that cannot be detected via standard DOM events.
|
|
4
|
-
|
|
5
|
-
## Installation
|
|
6
|
-
|
|
7
|
-
```bash
|
|
8
|
-
npm install simen-keyboard-listener
|
|
9
|
-
```
|
|
10
|
-
|
|
11
|
-
## Usage
|
|
12
|
-
|
|
13
|
-
```typescript
|
|
14
|
-
import { getGlobalKeyboardListener } from 'simen-keyboard-listener';
|
|
15
|
-
|
|
16
|
-
const listener = getGlobalKeyboardListener();
|
|
17
|
-
|
|
18
|
-
listener.addListener((event, isDown) => {
|
|
19
|
-
console.log(`Key: ${event.name}, State: ${event.state}`);
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
// Later, to stop listening:
|
|
23
|
-
listener.removeListener(myListener);
|
|
24
|
-
```
|
|
25
|
-
|
|
26
|
-
## API
|
|
27
|
-
|
|
28
|
-
### `getGlobalKeyboardListener(): IGlobalKeyboardListener`
|
|
29
|
-
|
|
30
|
-
Returns the singleton keyboard listener instance.
|
|
31
|
-
|
|
32
|
-
### `IGlobalKeyboardListener`
|
|
33
|
-
|
|
34
|
-
- `addListener(listener: IGlobalKeyListener): void` - Add a key event listener
|
|
35
|
-
- `removeListener(listener: IGlobalKeyListener): void` - Remove a listener
|
|
36
|
-
- `kill(): void` - Stop the listener (only when no listeners remain)
|
|
37
|
-
|
|
38
|
-
### `IGlobalKeyEvent`
|
|
39
|
-
|
|
40
|
-
```typescript
|
|
41
|
-
interface IGlobalKeyEvent {
|
|
42
|
-
readonly name: string; // e.g. "FN", "LEFT SHIFT", "A", "ESCAPE"
|
|
43
|
-
readonly state: 'DOWN' | 'UP';
|
|
44
|
-
}
|
|
45
|
-
```
|
|
46
|
-
|
|
47
|
-
## Supported Keys
|
|
48
|
-
|
|
49
|
-
- **Modifiers**: FN (macOS), SHIFT, CTRL, ALT, META (Cmd/Win)
|
|
50
|
-
- **Letters**: A-Z
|
|
51
|
-
- **Numbers**: 0-9
|
|
52
|
-
- **Function keys**: F1-F12 (Windows)
|
|
53
|
-
- **Special**: ESCAPE, SPACE, RETURN, TAB, BACKSPACE, DELETE
|
|
54
|
-
- **Arrows**: UP, DOWN, LEFT, RIGHT
|
|
55
|
-
|
|
56
|
-
## Platform Support
|
|
57
|
-
|
|
58
|
-
- macOS (x64, arm64)
|
|
59
|
-
- Windows (x64, arm64)
|
|
60
|
-
|
|
61
|
-
## Requirements
|
|
62
|
-
|
|
63
|
-
- Node.js >= 18.0.0
|
|
64
|
-
- macOS: Accessibility permission required
|
|
65
|
-
- Windows: No special permissions needed
|
|
66
|
-
|
|
67
|
-
## License
|
|
68
|
-
|
|
69
|
-
MIT
|
|
1
|
+
# simen-keyboard-listener
|
|
2
|
+
|
|
3
|
+
Native global keyboard listener for macOS and Windows. Captures keyboard events system-wide, including special keys like FN that cannot be detected via standard DOM events.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install simen-keyboard-listener
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
import { getGlobalKeyboardListener } from 'simen-keyboard-listener';
|
|
15
|
+
|
|
16
|
+
const listener = getGlobalKeyboardListener();
|
|
17
|
+
|
|
18
|
+
listener.addListener((event, isDown) => {
|
|
19
|
+
console.log(`Key: ${event.name}, State: ${event.state}`);
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
// Later, to stop listening:
|
|
23
|
+
listener.removeListener(myListener);
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## API
|
|
27
|
+
|
|
28
|
+
### `getGlobalKeyboardListener(): IGlobalKeyboardListener`
|
|
29
|
+
|
|
30
|
+
Returns the singleton keyboard listener instance.
|
|
31
|
+
|
|
32
|
+
### `IGlobalKeyboardListener`
|
|
33
|
+
|
|
34
|
+
- `addListener(listener: IGlobalKeyListener): void` - Add a key event listener
|
|
35
|
+
- `removeListener(listener: IGlobalKeyListener): void` - Remove a listener
|
|
36
|
+
- `kill(): void` - Stop the listener (only when no listeners remain)
|
|
37
|
+
|
|
38
|
+
### `IGlobalKeyEvent`
|
|
39
|
+
|
|
40
|
+
```typescript
|
|
41
|
+
interface IGlobalKeyEvent {
|
|
42
|
+
readonly name: string; // e.g. "FN", "LEFT SHIFT", "A", "ESCAPE"
|
|
43
|
+
readonly state: 'DOWN' | 'UP';
|
|
44
|
+
}
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## Supported Keys
|
|
48
|
+
|
|
49
|
+
- **Modifiers**: FN (macOS), SHIFT, CTRL, ALT, META (Cmd/Win)
|
|
50
|
+
- **Letters**: A-Z
|
|
51
|
+
- **Numbers**: 0-9
|
|
52
|
+
- **Function keys**: F1-F12 (Windows)
|
|
53
|
+
- **Special**: ESCAPE, SPACE, RETURN, TAB, BACKSPACE, DELETE
|
|
54
|
+
- **Arrows**: UP, DOWN, LEFT, RIGHT
|
|
55
|
+
|
|
56
|
+
## Platform Support
|
|
57
|
+
|
|
58
|
+
- macOS (x64, arm64)
|
|
59
|
+
- Windows (x64, arm64)
|
|
60
|
+
|
|
61
|
+
## Requirements
|
|
62
|
+
|
|
63
|
+
- Node.js >= 18.0.0
|
|
64
|
+
- macOS: Accessibility permission required
|
|
65
|
+
- Windows: No special permissions needed
|
|
66
|
+
|
|
67
|
+
## License
|
|
68
|
+
|
|
69
|
+
MIT
|
package/package.json
CHANGED
|
@@ -1,58 +1,58 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "simen-keyboard-listener",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"description": "Native global keyboard listener for macOS and Windows",
|
|
5
|
-
"main": "./dist/index.js",
|
|
6
|
-
"module": "./dist/index.mjs",
|
|
7
|
-
"types": "./dist/index.d.ts",
|
|
8
|
-
"exports": {
|
|
9
|
-
".": {
|
|
10
|
-
"types": "./dist/index.d.ts",
|
|
11
|
-
"import": "./dist/index.mjs",
|
|
12
|
-
"require": "./dist/index.js"
|
|
13
|
-
}
|
|
14
|
-
},
|
|
15
|
-
"files": [
|
|
16
|
-
"dist",
|
|
17
|
-
"prebuilds",
|
|
18
|
-
"src/native/prebuilds",
|
|
19
|
-
"src/native/binding.gyp",
|
|
20
|
-
"src/native/package.json",
|
|
21
|
-
"src/native/simen_keyboard_listener.cc"
|
|
22
|
-
],
|
|
23
|
-
"scripts": {
|
|
24
|
-
"build:native": "node-gyp rebuild --directory=src/native",
|
|
25
|
-
"build:ts": "tsup src/index.ts --format cjs,esm --dts --clean",
|
|
26
|
-
"build": "npm run build:native && npm run build:ts",
|
|
27
|
-
"prebuild": "prebuildify --napi --strip --cwd src/native",
|
|
28
|
-
"prepublishOnly": "npm run build:ts"
|
|
29
|
-
},
|
|
30
|
-
"keywords": [
|
|
31
|
-
"keyboard",
|
|
32
|
-
"hotkey",
|
|
33
|
-
"global",
|
|
34
|
-
"native",
|
|
35
|
-
"addon",
|
|
36
|
-
"macos",
|
|
37
|
-
"windows"
|
|
38
|
-
],
|
|
39
|
-
"author": "Simen",
|
|
40
|
-
"license": "MIT",
|
|
41
|
-
"repository": {
|
|
42
|
-
"type": "git",
|
|
43
|
-
"url": "https://github.com/user/simen-keyboard-listener"
|
|
44
|
-
},
|
|
45
|
-
"engines": {
|
|
46
|
-
"node": ">=18.0.0"
|
|
47
|
-
},
|
|
48
|
-
"dependencies": {
|
|
49
|
-
"node-addon-api": "^8.0.0"
|
|
50
|
-
},
|
|
51
|
-
"devDependencies": {
|
|
52
|
-
"@types/node": "^20.0.0",
|
|
53
|
-
"node-gyp": "^10.0.0",
|
|
54
|
-
"prebuildify": "^6.0.1",
|
|
55
|
-
"tsup": "^8.0.0",
|
|
56
|
-
"typescript": "^5.0.0"
|
|
57
|
-
}
|
|
58
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "simen-keyboard-listener",
|
|
3
|
+
"version": "1.0.4",
|
|
4
|
+
"description": "Native global keyboard listener for macOS and Windows",
|
|
5
|
+
"main": "./dist/index.js",
|
|
6
|
+
"module": "./dist/index.mjs",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.mjs",
|
|
12
|
+
"require": "./dist/index.js"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist",
|
|
17
|
+
"prebuilds",
|
|
18
|
+
"src/native/prebuilds",
|
|
19
|
+
"src/native/binding.gyp",
|
|
20
|
+
"src/native/package.json",
|
|
21
|
+
"src/native/simen_keyboard_listener.cc"
|
|
22
|
+
],
|
|
23
|
+
"scripts": {
|
|
24
|
+
"build:native": "node-gyp rebuild --directory=src/native",
|
|
25
|
+
"build:ts": "tsup src/index.ts --format cjs,esm --dts --clean",
|
|
26
|
+
"build": "npm run build:native && npm run build:ts",
|
|
27
|
+
"prebuild": "prebuildify --napi --strip --cwd src/native",
|
|
28
|
+
"prepublishOnly": "npm run build:ts"
|
|
29
|
+
},
|
|
30
|
+
"keywords": [
|
|
31
|
+
"keyboard",
|
|
32
|
+
"hotkey",
|
|
33
|
+
"global",
|
|
34
|
+
"native",
|
|
35
|
+
"addon",
|
|
36
|
+
"macos",
|
|
37
|
+
"windows"
|
|
38
|
+
],
|
|
39
|
+
"author": "Simen",
|
|
40
|
+
"license": "MIT",
|
|
41
|
+
"repository": {
|
|
42
|
+
"type": "git",
|
|
43
|
+
"url": "https://github.com/user/simen-keyboard-listener"
|
|
44
|
+
},
|
|
45
|
+
"engines": {
|
|
46
|
+
"node": ">=18.0.0"
|
|
47
|
+
},
|
|
48
|
+
"dependencies": {
|
|
49
|
+
"node-addon-api": "^8.0.0"
|
|
50
|
+
},
|
|
51
|
+
"devDependencies": {
|
|
52
|
+
"@types/node": "^20.0.0",
|
|
53
|
+
"node-gyp": "^10.0.0",
|
|
54
|
+
"prebuildify": "^6.0.1",
|
|
55
|
+
"tsup": "^8.0.0",
|
|
56
|
+
"typescript": "^5.0.0"
|
|
57
|
+
}
|
|
58
|
+
}
|
package/src/native/binding.gyp
CHANGED
|
@@ -1,40 +1,40 @@
|
|
|
1
|
-
{
|
|
2
|
-
"targets": [
|
|
3
|
-
{
|
|
4
|
-
"target_name": "simen_keyboard_listener",
|
|
5
|
-
"sources": [
|
|
6
|
-
"simen_keyboard_listener.cc"
|
|
7
|
-
],
|
|
8
|
-
"include_dirs": [
|
|
9
|
-
"<!@(node -p \"require('node-addon-api').include\")"
|
|
10
|
-
],
|
|
11
|
-
"defines": [
|
|
12
|
-
"NAPI_DISABLE_CPP_EXCEPTIONS"
|
|
13
|
-
],
|
|
14
|
-
"cflags!": [ "-fno-exceptions" ],
|
|
15
|
-
"cflags_cc!": [ "-fno-exceptions" ],
|
|
16
|
-
"xcode_settings": {
|
|
17
|
-
"GCC_ENABLE_CPP_EXCEPTIONS": "NO",
|
|
18
|
-
"CLANG_CXX_LIBRARY": "libc++",
|
|
19
|
-
"MACOSX_DEPLOYMENT_TARGET": "11.0"
|
|
20
|
-
},
|
|
21
|
-
"msvs_settings": {
|
|
22
|
-
"VCCLCompilerTool": { "ExceptionHandling": 0 }
|
|
23
|
-
},
|
|
24
|
-
"conditions": [
|
|
25
|
-
["OS=='mac'", {
|
|
26
|
-
"xcode_settings": {
|
|
27
|
-
"OTHER_LDFLAGS": [
|
|
28
|
-
"-framework", "ApplicationServices"
|
|
29
|
-
]
|
|
30
|
-
}
|
|
31
|
-
}],
|
|
32
|
-
["OS=='win'", {
|
|
33
|
-
"libraries": [
|
|
34
|
-
"User32.lib"
|
|
35
|
-
]
|
|
36
|
-
}]
|
|
37
|
-
]
|
|
38
|
-
}
|
|
39
|
-
]
|
|
40
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"targets": [
|
|
3
|
+
{
|
|
4
|
+
"target_name": "simen_keyboard_listener",
|
|
5
|
+
"sources": [
|
|
6
|
+
"simen_keyboard_listener.cc"
|
|
7
|
+
],
|
|
8
|
+
"include_dirs": [
|
|
9
|
+
"<!@(node -p \"require('node-addon-api').include\")"
|
|
10
|
+
],
|
|
11
|
+
"defines": [
|
|
12
|
+
"NAPI_DISABLE_CPP_EXCEPTIONS"
|
|
13
|
+
],
|
|
14
|
+
"cflags!": [ "-fno-exceptions" ],
|
|
15
|
+
"cflags_cc!": [ "-fno-exceptions" ],
|
|
16
|
+
"xcode_settings": {
|
|
17
|
+
"GCC_ENABLE_CPP_EXCEPTIONS": "NO",
|
|
18
|
+
"CLANG_CXX_LIBRARY": "libc++",
|
|
19
|
+
"MACOSX_DEPLOYMENT_TARGET": "11.0"
|
|
20
|
+
},
|
|
21
|
+
"msvs_settings": {
|
|
22
|
+
"VCCLCompilerTool": { "ExceptionHandling": 0 }
|
|
23
|
+
},
|
|
24
|
+
"conditions": [
|
|
25
|
+
["OS=='mac'", {
|
|
26
|
+
"xcode_settings": {
|
|
27
|
+
"OTHER_LDFLAGS": [
|
|
28
|
+
"-framework", "ApplicationServices"
|
|
29
|
+
]
|
|
30
|
+
}
|
|
31
|
+
}],
|
|
32
|
+
["OS=='win'", {
|
|
33
|
+
"libraries": [
|
|
34
|
+
"User32.lib"
|
|
35
|
+
]
|
|
36
|
+
}]
|
|
37
|
+
]
|
|
38
|
+
}
|
|
39
|
+
]
|
|
40
|
+
}
|
package/src/native/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "simen-keyboard-listener-native",
|
|
3
|
-
"version": "1.0.0",
|
|
4
|
-
"private": true,
|
|
5
|
-
"gypfile": true,
|
|
6
|
-
"scripts": {
|
|
7
|
-
"install": "node-gyp rebuild",
|
|
8
|
-
"build": "node-gyp rebuild",
|
|
9
|
-
"clean": "node-gyp clean"
|
|
10
|
-
},
|
|
11
|
-
"dependencies": {
|
|
12
|
-
"node-addon-api": "^8.0.0"
|
|
13
|
-
}
|
|
14
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "simen-keyboard-listener-native",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"private": true,
|
|
5
|
+
"gypfile": true,
|
|
6
|
+
"scripts": {
|
|
7
|
+
"install": "node-gyp rebuild",
|
|
8
|
+
"build": "node-gyp rebuild",
|
|
9
|
+
"clean": "node-gyp clean"
|
|
10
|
+
},
|
|
11
|
+
"dependencies": {
|
|
12
|
+
"node-addon-api": "^8.0.0"
|
|
13
|
+
}
|
|
14
|
+
}
|