@headless-tree/core 0.0.0-20260108162121 → 0.0.0-20260109213608

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/CHANGELOG.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @headless-tree/core
2
2
 
3
- ## 0.0.0-20260108162121
3
+ ## 0.0.0-20260109213608
4
4
 
5
5
  ### Patch Changes
6
6
 
package/dist/index.js CHANGED
@@ -1025,6 +1025,7 @@ var checkboxesFeature = {
1025
1025
  };
1026
1026
 
1027
1027
  // src/features/hotkeys-core/feature.ts
1028
+ var resolveKeyCode = (e) => e.code !== "" && e.code !== "Unidentified" ? e.code : e.key;
1028
1029
  var specialKeys = {
1029
1030
  // TODO:breaking deprecate auto-lowercase
1030
1031
  letter: /^Key[A-Z]$/,
@@ -1073,9 +1074,10 @@ var hotkeysCoreFeature = {
1073
1074
  if (e.target instanceof HTMLInputElement && ignoreHotkeysOnInputs) {
1074
1075
  return;
1075
1076
  }
1077
+ const resolvedCode = resolveKeyCode(e);
1076
1078
  (_b = (_a = data.current).pressedKeys) != null ? _b : _a.pressedKeys = /* @__PURE__ */ new Set();
1077
- const newMatch = !data.current.pressedKeys.has(e.code);
1078
- data.current.pressedKeys.add(e.code);
1079
+ const newMatch = !data.current.pressedKeys.has(resolvedCode);
1080
+ data.current.pressedKeys.add(resolvedCode);
1079
1081
  const hotkeyName = findHotkeyMatch(
1080
1082
  data.current.pressedKeys,
1081
1083
  tree,
@@ -1083,7 +1085,7 @@ var hotkeysCoreFeature = {
1083
1085
  hotkeys
1084
1086
  );
1085
1087
  if (e.target instanceof HTMLInputElement) {
1086
- data.current.pressedKeys.delete(e.code);
1088
+ data.current.pressedKeys.delete(resolvedCode);
1087
1089
  }
1088
1090
  if (!hotkeyName) return;
1089
1091
  const hotkeyConfig = __spreadValues(__spreadValues({}, tree.getHotkeyPresets()[hotkeyName]), hotkeys == null ? void 0 : hotkeys[hotkeyName]);
@@ -1098,7 +1100,7 @@ var hotkeysCoreFeature = {
1098
1100
  const keyup = (e) => {
1099
1101
  var _a, _b;
1100
1102
  (_b = (_a = data.current).pressedKeys) != null ? _b : _a.pressedKeys = /* @__PURE__ */ new Set();
1101
- data.current.pressedKeys.delete(e.code);
1103
+ data.current.pressedKeys.delete(resolveKeyCode(e));
1102
1104
  };
1103
1105
  const reset = () => {
1104
1106
  data.current.pressedKeys = /* @__PURE__ */ new Set();
package/dist/index.mjs CHANGED
@@ -981,6 +981,7 @@ var checkboxesFeature = {
981
981
  };
982
982
 
983
983
  // src/features/hotkeys-core/feature.ts
984
+ var resolveKeyCode = (e) => e.code !== "" && e.code !== "Unidentified" ? e.code : e.key;
984
985
  var specialKeys = {
985
986
  // TODO:breaking deprecate auto-lowercase
986
987
  letter: /^Key[A-Z]$/,
@@ -1029,9 +1030,10 @@ var hotkeysCoreFeature = {
1029
1030
  if (e.target instanceof HTMLInputElement && ignoreHotkeysOnInputs) {
1030
1031
  return;
1031
1032
  }
1033
+ const resolvedCode = resolveKeyCode(e);
1032
1034
  (_b = (_a = data.current).pressedKeys) != null ? _b : _a.pressedKeys = /* @__PURE__ */ new Set();
1033
- const newMatch = !data.current.pressedKeys.has(e.code);
1034
- data.current.pressedKeys.add(e.code);
1035
+ const newMatch = !data.current.pressedKeys.has(resolvedCode);
1036
+ data.current.pressedKeys.add(resolvedCode);
1035
1037
  const hotkeyName = findHotkeyMatch(
1036
1038
  data.current.pressedKeys,
1037
1039
  tree,
@@ -1039,7 +1041,7 @@ var hotkeysCoreFeature = {
1039
1041
  hotkeys
1040
1042
  );
1041
1043
  if (e.target instanceof HTMLInputElement) {
1042
- data.current.pressedKeys.delete(e.code);
1044
+ data.current.pressedKeys.delete(resolvedCode);
1043
1045
  }
1044
1046
  if (!hotkeyName) return;
1045
1047
  const hotkeyConfig = __spreadValues(__spreadValues({}, tree.getHotkeyPresets()[hotkeyName]), hotkeys == null ? void 0 : hotkeys[hotkeyName]);
@@ -1054,7 +1056,7 @@ var hotkeysCoreFeature = {
1054
1056
  const keyup = (e) => {
1055
1057
  var _a, _b;
1056
1058
  (_b = (_a = data.current).pressedKeys) != null ? _b : _a.pressedKeys = /* @__PURE__ */ new Set();
1057
- data.current.pressedKeys.delete(e.code);
1059
+ data.current.pressedKeys.delete(resolveKeyCode(e));
1058
1060
  };
1059
1061
  const reset = () => {
1060
1062
  data.current.pressedKeys = /* @__PURE__ */ new Set();
package/package.json CHANGED
@@ -13,7 +13,7 @@
13
13
  "checkbox",
14
14
  "hook"
15
15
  ],
16
- "version": "0.0.0-20260108162121",
16
+ "version": "0.0.0-20260109213608",
17
17
  "main": "dist/index.d.ts",
18
18
  "module": "dist/index.mjs",
19
19
  "types": "dist/index.d.mts",
@@ -5,6 +5,11 @@ import {
5
5
  } from "../../types/core";
6
6
  import { HotkeyConfig, HotkeysCoreDataRef } from "./types";
7
7
 
8
+ // e.code may be empty or "Unidentified" on mobile virtual keyboards
9
+ // or during IME composition, so we fall back to e.key
10
+ const resolveKeyCode = (e: KeyboardEvent): string =>
11
+ e.code !== "" && e.code !== "Unidentified" ? e.code : e.key;
12
+
8
13
  const specialKeys: Record<string, RegExp> = {
9
14
  // TODO:breaking deprecate auto-lowercase
10
15
  letter: /^Key[A-Z]$/,
@@ -71,9 +76,11 @@ export const hotkeysCoreFeature: FeatureImplementation = {
71
76
  return;
72
77
  }
73
78
 
79
+ const resolvedCode = resolveKeyCode(e);
80
+
74
81
  data.current.pressedKeys ??= new Set();
75
- const newMatch = !data.current.pressedKeys.has(e.code);
76
- data.current.pressedKeys.add(e.code);
82
+ const newMatch = !data.current.pressedKeys.has(resolvedCode);
83
+ data.current.pressedKeys.add(resolvedCode);
77
84
 
78
85
  const hotkeyName = findHotkeyMatch(
79
86
  data.current.pressedKeys,
@@ -85,7 +92,7 @@ export const hotkeysCoreFeature: FeatureImplementation = {
85
92
  if (e.target instanceof HTMLInputElement) {
86
93
  // JS respects composite keydowns while input elements are focused, and
87
94
  // doesnt send the associated keyup events with the same key name
88
- data.current.pressedKeys.delete(e.code);
95
+ data.current.pressedKeys.delete(resolvedCode);
89
96
  }
90
97
 
91
98
  if (!hotkeyName) return;
@@ -110,7 +117,7 @@ export const hotkeysCoreFeature: FeatureImplementation = {
110
117
 
111
118
  const keyup = (e: KeyboardEvent) => {
112
119
  data.current.pressedKeys ??= new Set();
113
- data.current.pressedKeys.delete(e.code);
120
+ data.current.pressedKeys.delete(resolveKeyCode(e));
114
121
  };
115
122
 
116
123
  const reset = () => {