qdesk 1.0.1 → 1.0.3

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.
@@ -1,4 +1,5 @@
1
1
  import { CallNextHookEx, decodeKeyboardHookLParam, DispatchMessageW, GetAsyncKeyState, GetMessageW, GetModuleHandleW, registerKeyboardHookCallback, SetWindowsHookExW, TranslateMessage, UnhookWindowsHookEx, unregisterCallback, } from "./koffi-utils.js";
2
+ const process = globalThis.process;
2
3
  const MOD_ALT = 0x0001;
3
4
  const MOD_CONTROL = 0x0002;
4
5
  const MOD_SHIFT = 0x0004;
@@ -6,6 +7,7 @@ const MOD_WIN = 0x0008;
6
7
  const VK_SHIFT = 0x10;
7
8
  const VK_CONTROL = 0x11;
8
9
  const VK_MENU = 0x12;
10
+ const VK_ESCAPE = 0x1b;
9
11
  const VK_LWIN = 0x5b;
10
12
  const VK_RWIN = 0x5c;
11
13
  const HC_ACTION = 0;
@@ -164,11 +166,20 @@ export function startListening(options) {
164
166
  return passThrough();
165
167
  }
166
168
  const kb = decodeKeyboardHookLParam(lParam);
167
- const combo = buildCurrentChord(Number(kb.vkCode));
169
+ const vkCode = Number(kb.vkCode);
170
+ let shouldStopPropagation = false;
171
+ if (vkCode === VK_ESCAPE) {
172
+ options.onEscape?.(() => {
173
+ shouldStopPropagation = true;
174
+ });
175
+ if (shouldStopPropagation) {
176
+ return 1n;
177
+ }
178
+ }
179
+ const combo = buildCurrentChord(vkCode);
168
180
  if (!combo) {
169
181
  return passThrough();
170
182
  }
171
- let shouldStopPropagation = false;
172
183
  if (activationNormalized && combo === activationNormalized) {
173
184
  options.onActivation?.(() => {
174
185
  shouldStopPropagation = true;
package/dist/index.js CHANGED
@@ -33,6 +33,22 @@ const toolWindowAtStartup = getActiveWindowHandleAndName() ?? undefined;
33
33
  console.log("[info] Tool window at startup:", toolWindowAtStartup?.name ?? "(unknown)");
34
34
  let removalReturnWindow;
35
35
  const listener = startListening({
36
+ onEscape: (stopPropagating) => {
37
+ if (!activeRecording && !awaitingChordRemoval) {
38
+ return;
39
+ }
40
+ if (activeRecording) {
41
+ console.log("[add] Canceled recording mode via Escape.");
42
+ activeRecording = undefined;
43
+ }
44
+ if (awaitingChordRemoval) {
45
+ console.log("[drop] Canceled removal mode via Escape.");
46
+ awaitingChordRemoval = false;
47
+ }
48
+ setScreenHue("off");
49
+ printBindings();
50
+ stopPropagating();
51
+ },
36
52
  onChord: (chord, stopPropagating) => {
37
53
  if (activeRecording) {
38
54
  if ([ADD_CHORD, DROP_CHORD].includes(chord)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "qdesk",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "type": "module",
5
5
  "repository": {
6
6
  "type": "git",
@@ -11,11 +11,18 @@
11
11
  },
12
12
  "homepage": "https://github.com/JakeBeaver/qdesk#readme",
13
13
  "bin": {
14
- "switcher": "dist/index.js"
14
+ "qdesk": "dist/index.js"
15
15
  },
16
16
  "files": [
17
17
  "dist"
18
18
  ],
19
+ "scripts": {
20
+ "dev": "tsx src/index.ts",
21
+ "clean": "node -e \"require('node:fs').rmSync('dist',{recursive:true,force:true})\"",
22
+ "build": "pnpm clean && tsc -p tsconfig.json",
23
+ "start": "node dist/index.js",
24
+ "prepack": "pnpm build"
25
+ },
19
26
  "dependencies": {
20
27
  "koffi": "^3.0.2"
21
28
  },
@@ -23,11 +30,5 @@
23
30
  "@types/node": "^22.15.30",
24
31
  "tsx": "^4.19.4",
25
32
  "typescript": "^5.8.3"
26
- },
27
- "scripts": {
28
- "dev": "tsx src/index.ts",
29
- "clean": "node -e \"require('node:fs').rmSync('dist',{recursive:true,force:true})\"",
30
- "build": "pnpm clean && tsc -p tsconfig.json",
31
- "start": "node dist/index.js"
32
33
  }
33
- }
34
+ }