simen-keyboard-listener 1.0.4 → 1.0.5

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 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/dist/index.js CHANGED
@@ -56,11 +56,9 @@ function getNativeAddonPath() {
56
56
  const platformArch = `${process.platform}-${process.arch}`;
57
57
  const baseDir = modulePaths.dirname;
58
58
  const possiblePaths = [
59
- // Prebuilt binaries (preferred) - prebuildify generates with package name
59
+ // Prebuilt binaries (preferred)
60
60
  path.join(baseDir, "..", "prebuilds", platformArch, "simen-keyboard-listener-native.node"),
61
61
  path.join(baseDir, "..", "prebuilds", platformArch, "simen_keyboard_listener.node"),
62
- // Prebuilds in src/native (from prebuildify --cwd src/native)
63
- path.join(baseDir, "..", "src", "native", "prebuilds", platformArch, "simen-keyboard-listener-native.node"),
64
62
  // Build output from node-gyp
65
63
  path.join(baseDir, "native", "build", "Release", "simen_keyboard_listener.node"),
66
64
  path.join(baseDir, "native", "build", "Debug", "simen_keyboard_listener.node"),
package/dist/index.mjs CHANGED
@@ -27,11 +27,9 @@ function getNativeAddonPath() {
27
27
  const platformArch = `${process.platform}-${process.arch}`;
28
28
  const baseDir = modulePaths.dirname;
29
29
  const possiblePaths = [
30
- // Prebuilt binaries (preferred) - prebuildify generates with package name
30
+ // Prebuilt binaries (preferred)
31
31
  path.join(baseDir, "..", "prebuilds", platformArch, "simen-keyboard-listener-native.node"),
32
32
  path.join(baseDir, "..", "prebuilds", platformArch, "simen_keyboard_listener.node"),
33
- // Prebuilds in src/native (from prebuildify --cwd src/native)
34
- path.join(baseDir, "..", "src", "native", "prebuilds", platformArch, "simen-keyboard-listener-native.node"),
35
33
  // Build output from node-gyp
36
34
  path.join(baseDir, "native", "build", "Release", "simen_keyboard_listener.node"),
37
35
  path.join(baseDir, "native", "build", "Debug", "simen_keyboard_listener.node"),
package/package.json CHANGED
@@ -1,58 +1,57 @@
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
- }
1
+ {
2
+ "name": "simen-keyboard-listener",
3
+ "version": "1.0.5",
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/binding.gyp",
19
+ "src/native/package.json",
20
+ "src/native/simen_keyboard_listener.cc"
21
+ ],
22
+ "scripts": {
23
+ "build:native": "node-gyp rebuild --directory=src/native",
24
+ "build:ts": "tsup src/index.ts --format cjs,esm --dts --clean",
25
+ "build": "npm run build:native && npm run build:ts",
26
+ "prebuild": "prebuildify --napi --strip --cwd src/native",
27
+ "prepublishOnly": "npm run build:ts"
28
+ },
29
+ "keywords": [
30
+ "keyboard",
31
+ "hotkey",
32
+ "global",
33
+ "native",
34
+ "addon",
35
+ "macos",
36
+ "windows"
37
+ ],
38
+ "author": "Simen",
39
+ "license": "MIT",
40
+ "repository": {
41
+ "type": "git",
42
+ "url": "https://github.com/user/simen-keyboard-listener"
43
+ },
44
+ "engines": {
45
+ "node": ">=18.0.0"
46
+ },
47
+ "dependencies": {
48
+ "node-addon-api": "^8.0.0"
49
+ },
50
+ "devDependencies": {
51
+ "@types/node": "^20.0.0",
52
+ "node-gyp": "^10.0.0",
53
+ "prebuildify": "^6.0.1",
54
+ "tsup": "^8.0.0",
55
+ "typescript": "^5.0.0"
56
+ }
57
+ }
@@ -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
+ }
@@ -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
+ }