@solid-primitives/keyboard 1.0.9-beta.0 → 1.0.9

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) 2021 Solid Primitives Working Group
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
1
+ MIT License
2
+
3
+ Copyright (c) 2021 Solid Primitives Working Group
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
21
  SOFTWARE.
package/README.md CHANGED
@@ -1,158 +1,158 @@
1
- <p>
2
- <img width="100%" src="https://assets.solidjs.com/banner?type=Primitives&background=tiles&project=keyboard" alt="Solid Primitives keyboard">
3
- </p>
4
-
5
- # @solid-primitives/keyboard
6
-
7
- [![lerna](https://img.shields.io/badge/maintained%20with-lerna-cc00ff.svg?style=for-the-badge)](https://lerna.js.org/)
8
- [![size](https://img.shields.io/bundlephobia/minzip/@solid-primitives/keyboard?style=for-the-badge&label=size)](https://bundlephobia.com/package/@solid-primitives/keyboard)
9
- [![version](https://img.shields.io/npm/v/@solid-primitives/keyboard?style=for-the-badge)](https://www.npmjs.com/package/@solid-primitives/keyboard)
10
- [![stage](https://img.shields.io/endpoint?style=for-the-badge&url=https%3A%2F%2Fraw.githubusercontent.com%2Fsolidjs-community%2Fsolid-primitives%2Fmain%2Fassets%2Fbadges%2Fstage-1.json)](https://github.com/solidjs-community/solid-primitives#contribution-process)
11
-
12
- A library of reactive promitives helping handling user's keyboard input.
13
-
14
- - [`useKeyDownList`](#useKeyDownList) — Provides a signal with the list of currently held keys
15
- - [`useCurrentlyHeldKey`](#useCurrentlyHeldKey) — Provides a signal with the currently held single key.
16
- - [`useKeyDownSequence`](#useKeyDownSequence) — Provides a signal with a sequence of currently held keys, as they were pressed down and up.
17
- - [`createKeyHold`](#createKeyHold) — Provides a signal indicating if provided key is currently being held down.
18
- - [`createShortcut`](#createShortcut) — Creates a keyboard shotcut observer.
19
-
20
- ## Installation
21
-
22
- ```bash
23
- npm install @solid-primitives/keyboard
24
- # or
25
- yarn add @solid-primitives/keyboard
26
- ```
27
-
28
- ## `useKeyDownList`
29
-
30
- Provides a signal with the list of currently held keys, ordered from least recent to most recent.
31
-
32
- This is a [shared root](https://github.com/solidjs-community/solid-primitives/tree/main/packages/rootless#createSharedRoot) primitive that will reuse event listeners and signals across dependents.
33
-
34
- ### How to use it
35
-
36
- `useKeyDownList` takes no arguments, and returns a signal with the list of currently held keys, and last keydown event.
37
-
38
- ```tsx
39
- import { useKeyDownList } from "@solid-primitives/keyboard";
40
-
41
- const [keys, { event }] = useKeyDownList();
42
-
43
- createEffect(() => {
44
- console.log(keys()); // => string[] — list of currently held keys
45
- console.log(event()); // => KeyboardEvent | null — last keydown event
46
- });
47
-
48
- <For each={keys()}>
49
- {key => <kbd>{key}</kdb>}
50
- </For>
51
- ```
52
-
53
- ## `useCurrentlyHeldKey`
54
-
55
- Provides a signal with the currently held single key. Pressing any other key at the same time will reset the signal to `null`.
56
-
57
- This is a [shared root](https://github.com/solidjs-community/solid-primitives/tree/main/packages/rootless#createSharedRoot) primitive that will reuse event listeners and signals across dependents.
58
-
59
- ### How to use it
60
-
61
- `useCurrentlyHeldKey` takes no arguments, and returns a signal with the currently held single key.
62
-
63
- ```tsx
64
- import { useCurrentlyHeldKey } from "@solid-primitives/keyboard";
65
-
66
- const key = useCurrentlyHeldKey();
67
-
68
- createEffect(() => {
69
- console.log(key()); // => string | null — currently held key
70
- });
71
- ```
72
-
73
- ## `useKeyDownSequence`
74
-
75
- Provides a signal with a sequence of currently held keys, as they were pressed down and up.
76
-
77
- This is a [shared root](https://github.com/solidjs-community/solid-primitives/tree/main/packages/rootless#createSharedRoot) primitive that will reuse event listeners and signals across dependents.
78
-
79
- ### How to use it
80
-
81
- `useKeyDownSequence` takes no arguments, and returns a single signal.
82
-
83
- ```tsx
84
- import { useKeyDownSequence } from "@solid-primitives/keyboard";
85
-
86
- const sequence = useKeyDownSequence();
87
-
88
- createEffect(() => {
89
- console.log(sequence()); // => string[][] — sequence of currently held keys
90
- });
91
-
92
- // example sequence of pressing Ctrl + Shift + A
93
- // [["Control"], ["Control", "Shift"], ["Control", "Shift", "A"]]
94
- ```
95
-
96
- ## `createKeyHold`
97
-
98
- Provides a `boolean` signal indicating if provided key is currently being held down.
99
-
100
- Holding multiple keys at the same time will return `false` — holding only the specified one will return `true`.
101
-
102
- ### How to use it
103
-
104
- `createKeyHold` takes two arguments:
105
-
106
- - `key` keyboard key to listen for
107
- - `options` additional configuration:
108
- - `preventDefault` — call `e.preventDefault()` on the keyboard event, when the specified key is pressed. _(Defaults to `true`)_
109
-
110
- ```tsx
111
- import { createKeyHold } from "@solid-primitives/keyboard";
112
-
113
- const pressing = createKeyHold("Alt", { preventDefault: false });
114
-
115
- <p>Is pressing Alt? {pressing() ? "YES" : "NO"}</p>;
116
- ```
117
-
118
- ## `createShortcut`
119
-
120
- Creates a keyboard shotcut observer. The provided callback will be called when the specified keys are pressed.
121
-
122
- ### How to use it
123
-
124
- `createShortcut` takes three arguments:
125
-
126
- - `keys` — list of keys to listen for
127
- - `callback` — callback to call when the specified keys are pressed
128
- - `options` — additional configuration:
129
- - `preventDefault` — call `e.preventDefault()` on the keyboard event, when the specified key is pressed. _(Defaults to `true`)_
130
- - `requireReset` — If `true`, the shortcut will only be triggered once until all of the keys stop being pressed. Disabled by default.
131
-
132
- ```tsx
133
- import { createShortcut } from "@solid-primitives/keyboard";
134
-
135
- createShortcut(
136
- ["Control", "Shift", "A"],
137
- () => {
138
- console.log("Shortcut triggered");
139
- },
140
- { preventDefault: false, requireReset: true },
141
- );
142
- ```
143
-
144
- ### Preventing default
145
-
146
- When `preventDefault` is `true`, `e.preventDefault()` will be called not only on the keydown event that have triggered the callback, but it will **optimistically** also prevend the default behavior of every previous keydown that will have the possibility to lead to the shotcut being pressed.
147
-
148
- E.g. when listening for `Control + Shift + A`, all three keydown events will be prevented.
149
-
150
- ## DEMO
151
-
152
- Working demo of some of the primitives in keyboard package:
153
-
154
- https://codesandbox.io/s/solid-primitives-keyboard-demo-s2l84k?file=/index.tsx
155
-
156
- ## Changelog
157
-
158
- See [CHANGELOG.md](./CHANGELOG.md)
1
+ <p>
2
+ <img width="100%" src="https://assets.solidjs.com/banner?type=Primitives&background=tiles&project=keyboard" alt="Solid Primitives keyboard">
3
+ </p>
4
+
5
+ # @solid-primitives/keyboard
6
+
7
+ [![lerna](https://img.shields.io/badge/maintained%20with-lerna-cc00ff.svg?style=for-the-badge)](https://lerna.js.org/)
8
+ [![size](https://img.shields.io/bundlephobia/minzip/@solid-primitives/keyboard?style=for-the-badge&label=size)](https://bundlephobia.com/package/@solid-primitives/keyboard)
9
+ [![version](https://img.shields.io/npm/v/@solid-primitives/keyboard?style=for-the-badge)](https://www.npmjs.com/package/@solid-primitives/keyboard)
10
+ [![stage](https://img.shields.io/endpoint?style=for-the-badge&url=https%3A%2F%2Fraw.githubusercontent.com%2Fsolidjs-community%2Fsolid-primitives%2Fmain%2Fassets%2Fbadges%2Fstage-1.json)](https://github.com/solidjs-community/solid-primitives#contribution-process)
11
+
12
+ A library of reactive promitives helping handling user's keyboard input.
13
+
14
+ - [`useKeyDownList`](#useKeyDownList) — Provides a signal with the list of currently held keys
15
+ - [`useCurrentlyHeldKey`](#useCurrentlyHeldKey) — Provides a signal with the currently held single key.
16
+ - [`useKeyDownSequence`](#useKeyDownSequence) — Provides a signal with a sequence of currently held keys, as they were pressed down and up.
17
+ - [`createKeyHold`](#createKeyHold) — Provides a signal indicating if provided key is currently being held down.
18
+ - [`createShortcut`](#createShortcut) — Creates a keyboard shotcut observer.
19
+
20
+ ## Installation
21
+
22
+ ```bash
23
+ npm install @solid-primitives/keyboard
24
+ # or
25
+ yarn add @solid-primitives/keyboard
26
+ ```
27
+
28
+ ## `useKeyDownList`
29
+
30
+ Provides a signal with the list of currently held keys, ordered from least recent to most recent.
31
+
32
+ This is a [shared root](https://github.com/solidjs-community/solid-primitives/tree/main/packages/rootless#createSharedRoot) primitive that will reuse event listeners and signals across dependents.
33
+
34
+ ### How to use it
35
+
36
+ `useKeyDownList` takes no arguments, and returns a signal with the list of currently held keys, and last keydown event.
37
+
38
+ ```tsx
39
+ import { useKeyDownList } from "@solid-primitives/keyboard";
40
+
41
+ const [keys, { event }] = useKeyDownList();
42
+
43
+ createEffect(() => {
44
+ console.log(keys()); // => string[] — list of currently held keys
45
+ console.log(event()); // => KeyboardEvent | null — last keydown event
46
+ });
47
+
48
+ <For each={keys()}>
49
+ {key => <kbd>{key}</kdb>}
50
+ </For>
51
+ ```
52
+
53
+ ## `useCurrentlyHeldKey`
54
+
55
+ Provides a signal with the currently held single key. Pressing any other key at the same time will reset the signal to `null`.
56
+
57
+ This is a [shared root](https://github.com/solidjs-community/solid-primitives/tree/main/packages/rootless#createSharedRoot) primitive that will reuse event listeners and signals across dependents.
58
+
59
+ ### How to use it
60
+
61
+ `useCurrentlyHeldKey` takes no arguments, and returns a signal with the currently held single key.
62
+
63
+ ```tsx
64
+ import { useCurrentlyHeldKey } from "@solid-primitives/keyboard";
65
+
66
+ const key = useCurrentlyHeldKey();
67
+
68
+ createEffect(() => {
69
+ console.log(key()); // => string | null — currently held key
70
+ });
71
+ ```
72
+
73
+ ## `useKeyDownSequence`
74
+
75
+ Provides a signal with a sequence of currently held keys, as they were pressed down and up.
76
+
77
+ This is a [shared root](https://github.com/solidjs-community/solid-primitives/tree/main/packages/rootless#createSharedRoot) primitive that will reuse event listeners and signals across dependents.
78
+
79
+ ### How to use it
80
+
81
+ `useKeyDownSequence` takes no arguments, and returns a single signal.
82
+
83
+ ```tsx
84
+ import { useKeyDownSequence } from "@solid-primitives/keyboard";
85
+
86
+ const sequence = useKeyDownSequence();
87
+
88
+ createEffect(() => {
89
+ console.log(sequence()); // => string[][] — sequence of currently held keys
90
+ });
91
+
92
+ // example sequence of pressing Ctrl + Shift + A
93
+ // [["Control"], ["Control", "Shift"], ["Control", "Shift", "A"]]
94
+ ```
95
+
96
+ ## `createKeyHold`
97
+
98
+ Provides a `boolean` signal indicating if provided key is currently being held down.
99
+
100
+ Holding multiple keys at the same time will return `false` — holding only the specified one will return `true`.
101
+
102
+ ### How to use it
103
+
104
+ `createKeyHold` takes two arguments:
105
+
106
+ - `key` keyboard key to listen for
107
+ - `options` additional configuration:
108
+ - `preventDefault` — call `e.preventDefault()` on the keyboard event, when the specified key is pressed. _(Defaults to `true`)_
109
+
110
+ ```tsx
111
+ import { createKeyHold } from "@solid-primitives/keyboard";
112
+
113
+ const pressing = createKeyHold("Alt", { preventDefault: false });
114
+
115
+ <p>Is pressing Alt? {pressing() ? "YES" : "NO"}</p>;
116
+ ```
117
+
118
+ ## `createShortcut`
119
+
120
+ Creates a keyboard shotcut observer. The provided callback will be called when the specified keys are pressed.
121
+
122
+ ### How to use it
123
+
124
+ `createShortcut` takes three arguments:
125
+
126
+ - `keys` — list of keys to listen for
127
+ - `callback` — callback to call when the specified keys are pressed
128
+ - `options` — additional configuration:
129
+ - `preventDefault` — call `e.preventDefault()` on the keyboard event, when the specified key is pressed. _(Defaults to `true`)_
130
+ - `requireReset` — If `true`, the shortcut will only be triggered once until all of the keys stop being pressed. Disabled by default.
131
+
132
+ ```tsx
133
+ import { createShortcut } from "@solid-primitives/keyboard";
134
+
135
+ createShortcut(
136
+ ["Control", "Shift", "A"],
137
+ () => {
138
+ console.log("Shortcut triggered");
139
+ },
140
+ { preventDefault: false, requireReset: true },
141
+ );
142
+ ```
143
+
144
+ ### Preventing default
145
+
146
+ When `preventDefault` is `true`, `e.preventDefault()` will be called not only on the keydown event that have triggered the callback, but it will **optimistically** also prevend the default behavior of every previous keydown that will have the possibility to lead to the shotcut being pressed.
147
+
148
+ E.g. when listening for `Control + Shift + A`, all three keydown events will be prevented.
149
+
150
+ ## DEMO
151
+
152
+ Working demo of some of the primitives in keyboard package:
153
+
154
+ https://codesandbox.io/s/solid-primitives-keyboard-demo-s2l84k?file=/index.tsx
155
+
156
+ ## Changelog
157
+
158
+ See [CHANGELOG.md](./CHANGELOG.md)
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Accessor } from "solid-js";
1
+ import { Accessor } from 'solid-js';
2
2
 
3
3
  type ModifierKey = "Alt" | "Control" | "Meta" | "Shift";
4
4
  type KbdKey = ModifierKey | (string & {});
@@ -23,12 +23,9 @@ type KbdKey = ModifierKey | (string & {});
23
23
  * })
24
24
  * ```
25
25
  */
26
- declare const useKeyDownList: () => [
27
- keys: Accessor<string[]>,
28
- other: {
26
+ declare const useKeyDownList: () => [keys: Accessor<string[]>, other: {
29
27
  event: Accessor<KeyboardEvent | null>;
30
- },
31
- ];
28
+ }];
32
29
  /**
33
30
  * Provides a signal with the currently held single key. Pressing any other key at the same time will reset the signal to `null`.
34
31
  *
@@ -94,12 +91,9 @@ declare const useKeyDownSequence: () => Accessor<string[][]>;
94
91
  * })
95
92
  * ```
96
93
  */
97
- declare function createKeyHold(
98
- key: KbdKey,
99
- options?: {
94
+ declare function createKeyHold(key: KbdKey, options?: {
100
95
  preventDefault?: boolean;
101
- },
102
- ): Accessor<boolean>;
96
+ }): Accessor<boolean>;
103
97
  /**
104
98
  * Creates a keyboard shotcut observer. The provided {@link callback} will be called when the specified {@link keys} are pressed.
105
99
  *
@@ -118,21 +112,9 @@ declare function createKeyHold(
118
112
  * });
119
113
  * ```
120
114
  */
121
- declare function createShortcut(
122
- keys: KbdKey[],
123
- callback: VoidFunction,
124
- options?: {
115
+ declare function createShortcut(keys: KbdKey[], callback: VoidFunction, options?: {
125
116
  preventDefault?: boolean;
126
117
  requireReset?: boolean;
127
- },
128
- ): void;
118
+ }): void;
129
119
 
130
- export {
131
- KbdKey,
132
- ModifierKey,
133
- createKeyHold,
134
- createShortcut,
135
- useCurrentlyHeldKey,
136
- useKeyDownList,
137
- useKeyDownSequence,
138
- };
120
+ export { KbdKey, ModifierKey, createKeyHold, createShortcut, useCurrentlyHeldKey, useKeyDownList, useKeyDownSequence };
package/dist/index.js CHANGED
@@ -1,13 +1,14 @@
1
- import { makeEventListener } from "@solid-primitives/event-listener";
2
- import { createSharedRoot } from "@solid-primitives/rootless";
3
- import { arrayEquals } from "@solid-primitives/utils";
4
- import { createSignal, batch, untrack, createMemo, createEffect, on } from "solid-js";
1
+ import { makeEventListener } from '@solid-primitives/event-listener';
2
+ import { createSharedRoot } from '@solid-primitives/rootless';
3
+ import { arrayEquals } from '@solid-primitives/utils';
4
+ import { createSignal, batch, untrack, createMemo, createEffect, on } from 'solid-js';
5
5
 
6
6
  // src/index.ts
7
7
  function equalsKeyHoldSequence(sequence, model) {
8
8
  for (let i = sequence.length - 1; i >= 0; i--) {
9
9
  const _model = model.slice(0, i + 1);
10
- if (!arrayEquals(sequence[i], _model)) return false;
10
+ if (!arrayEquals(sequence[i], _model))
11
+ return false;
11
12
  }
12
13
  return true;
13
14
  }
@@ -15,22 +16,25 @@ var useKeyDownList = /* @__PURE__ */ createSharedRoot(() => {
15
16
  const [pressedKeys, setPressedKeys] = createSignal([]);
16
17
  const [event, setEvent] = createSignal(null);
17
18
  const reset = () => setPressedKeys([]);
18
- makeEventListener(window, "keydown", e => {
19
- if (e.repeat || typeof e.key !== "string") return;
19
+ makeEventListener(window, "keydown", (e) => {
20
+ if (e.repeat || typeof e.key !== "string")
21
+ return;
20
22
  const key = e.key.toUpperCase();
21
- if (pressedKeys().includes(key)) return;
23
+ if (pressedKeys().includes(key))
24
+ return;
22
25
  batch(() => {
23
26
  setEvent(e);
24
- setPressedKeys(prev => [...prev, key]);
27
+ setPressedKeys((prev) => [...prev, key]);
25
28
  });
26
29
  });
27
- makeEventListener(window, "keyup", e => {
28
- if (typeof e.key !== "string") return;
30
+ makeEventListener(window, "keyup", (e) => {
31
+ if (typeof e.key !== "string")
32
+ return;
29
33
  const key = e.key.toUpperCase();
30
- setPressedKeys(prev => prev.filter(_key => _key !== key));
34
+ setPressedKeys((prev) => prev.filter((_key) => _key !== key));
31
35
  });
32
36
  makeEventListener(window, "blur", reset);
33
- makeEventListener(window, "contextmenu", e => {
37
+ makeEventListener(window, "contextmenu", (e) => {
34
38
  e.defaultPrevented || reset();
35
39
  });
36
40
  return [pressedKeys, { event }];
@@ -42,14 +46,16 @@ var useCurrentlyHeldKey = /* @__PURE__ */ createSharedRoot(() => {
42
46
  const _keys = keys();
43
47
  const prev = prevKeys;
44
48
  prevKeys = _keys;
45
- if (prev.length === 0 && _keys.length === 1) return _keys[0];
49
+ if (prev.length === 0 && _keys.length === 1)
50
+ return _keys[0];
46
51
  return null;
47
52
  });
48
53
  });
49
54
  var useKeyDownSequence = /* @__PURE__ */ createSharedRoot(() => {
50
55
  const [keys] = useKeyDownList();
51
- return createMemo(prev => {
52
- if (keys().length === 0) return [];
56
+ return createMemo((prev) => {
57
+ if (keys().length === 0)
58
+ return [];
53
59
  return [...prev, keys()];
54
60
  }, []);
55
61
  });
@@ -70,14 +76,16 @@ function createShortcut(keys, callback, options = {}) {
70
76
  if (!keys.length) {
71
77
  return;
72
78
  }
73
- keys = keys.map(key => key.toUpperCase());
79
+ keys = keys.map((key) => key.toUpperCase());
74
80
  const { preventDefault = true, requireReset = false } = options;
75
81
  const [, { event }] = useKeyDownList();
76
82
  const sequence = useKeyDownSequence();
77
83
  let reset = false;
78
- const handleSequenceWithReset = sequence2 => {
79
- if (!sequence2.length) return (reset = false);
80
- if (reset) return;
84
+ const handleSequenceWithReset = (sequence2) => {
85
+ if (!sequence2.length)
86
+ return reset = false;
87
+ if (reset)
88
+ return;
81
89
  if (sequence2.length < keys.length) {
82
90
  if (equalsKeyHoldSequence(sequence2, keys.slice(0, sequence2.length))) {
83
91
  preventDefault && event().preventDefault();
@@ -92,9 +100,10 @@ function createShortcut(keys, callback, options = {}) {
92
100
  }
93
101
  }
94
102
  };
95
- const handleSequenceWithoutReset = sequence2 => {
103
+ const handleSequenceWithoutReset = (sequence2) => {
96
104
  const last = sequence2.at(-1);
97
- if (!last) return;
105
+ if (!last)
106
+ return;
98
107
  if (preventDefault && last.length < keys.length) {
99
108
  if (arrayEquals(last, keys.slice(0, keys.length - 1))) {
100
109
  event().preventDefault();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@solid-primitives/keyboard",
3
- "version": "1.0.9-beta.0",
3
+ "version": "1.0.9",
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": [],
@@ -81,9 +81,9 @@
81
81
  "require": "./dist/index.cjs"
82
82
  },
83
83
  "dependencies": {
84
- "@solid-primitives/event-listener": "^2.2.8-beta.0",
85
- "@solid-primitives/rootless": "^1.2.6-beta.0",
86
- "@solid-primitives/utils": "^5.4.0-beta.0"
84
+ "@solid-primitives/event-listener": "^2.2.8",
85
+ "@solid-primitives/rootless": "^1.2.6",
86
+ "@solid-primitives/utils": "^5.4.0"
87
87
  },
88
88
  "peerDependencies": {
89
89
  "solid-js": "^1.6.0"
package/dist/server.cjs DELETED
@@ -1,36 +0,0 @@
1
- 'use strict';
2
-
3
- require('@solid-primitives/event-listener');
4
- var rootless = require('@solid-primitives/rootless');
5
- require('@solid-primitives/utils');
6
- require('solid-js');
7
-
8
- // src/index.ts
9
- exports.useKeyDownList = /* @__PURE__ */ rootless.createSharedRoot(() => {
10
- {
11
- return [() => [], { event: () => null }];
12
- }
13
- });
14
- exports.useCurrentlyHeldKey = /* @__PURE__ */ rootless.createSharedRoot(() => {
15
- {
16
- return () => null;
17
- }
18
- });
19
- exports.useKeyDownSequence = /* @__PURE__ */ rootless.createSharedRoot(() => {
20
- {
21
- return () => [];
22
- }
23
- });
24
- function createKeyHold(key, options = {}) {
25
- {
26
- return () => false;
27
- }
28
- }
29
- function createShortcut(keys, callback, options = {}) {
30
- {
31
- return;
32
- }
33
- }
34
-
35
- exports.createKeyHold = createKeyHold;
36
- exports.createShortcut = createShortcut;
package/dist/server.js DELETED
@@ -1,33 +0,0 @@
1
- import "@solid-primitives/event-listener";
2
- import { createSharedRoot } from "@solid-primitives/rootless";
3
- import "@solid-primitives/utils";
4
- import "solid-js";
5
-
6
- // src/index.ts
7
- var useKeyDownList = /* @__PURE__ */ createSharedRoot(() => {
8
- {
9
- return [() => [], { event: () => null }];
10
- }
11
- });
12
- var useCurrentlyHeldKey = /* @__PURE__ */ createSharedRoot(() => {
13
- {
14
- return () => null;
15
- }
16
- });
17
- var useKeyDownSequence = /* @__PURE__ */ createSharedRoot(() => {
18
- {
19
- return () => [];
20
- }
21
- });
22
- function createKeyHold(key, options = {}) {
23
- {
24
- return () => false;
25
- }
26
- }
27
- function createShortcut(keys, callback, options = {}) {
28
- {
29
- return;
30
- }
31
- }
32
-
33
- export { createKeyHold, createShortcut, useCurrentlyHeldKey, useKeyDownList, useKeyDownSequence };