@solid-primitives/keyboard 2.0.0-next.0 → 2.0.0-next.1

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.
Files changed (2) hide show
  1. package/dist/index.js +18 -1
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -108,7 +108,16 @@ export const useKeyDownList = /*#__PURE__*/ createSingletonRoot(() => {
108
108
  if (typeof e.key !== "string")
109
109
  return;
110
110
  const key = e.key.toUpperCase();
111
- setPressedKeys(prev => prev.filter(_key => _key !== key));
111
+ // macOS never fires keyup for other keys held down together with Meta —
112
+ // only Meta's own keyup arrives — so its release must clear everything,
113
+ // or the other keys' stale state corrupts the next press.
114
+ // See https://github.com/solidjs-community/solid-primitives/issues/269
115
+ if (key === "META") {
116
+ reset();
117
+ }
118
+ else {
119
+ setPressedKeys(prev => prev.filter(_key => _key !== key));
120
+ }
112
121
  });
113
122
  makeEventListener(window, "blur", reset);
114
123
  makeEventListener(window, "contextmenu", e => {
@@ -328,6 +337,14 @@ export function createShortcut(keys, callback, options = {}) {
328
337
  if (typeof e.key !== "string")
329
338
  return;
330
339
  const key = e.key.toUpperCase();
340
+ // macOS never fires keyup for other keys held down together with Meta —
341
+ // only Meta's own keyup arrives. Treat it as a signal that every other
342
+ // tracked key must have been released too, or their stale state corrupts
343
+ // the next press (see https://github.com/solidjs-community/solid-primitives/issues/269).
344
+ if (key === "META") {
345
+ resetAll();
346
+ return;
347
+ }
331
348
  pressedKeys = pressedKeys.filter(k => k !== key);
332
349
  if (pressedKeys.length === 0) {
333
350
  sequence = [];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@solid-primitives/keyboard",
3
- "version": "2.0.0-next.0",
3
+ "version": "2.0.0-next.1",
4
4
  "description": "A library of reactive promitives helping handling user's keyboard input.",
5
5
  "author": "Damian Tarnwski <gthetarnav@gmail.com>",
6
6
  "contributors": [],