@solid-primitives/keyboard 1.0.12 → 1.1.0
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/dist/index.cjs +8 -6
- package/dist/index.d.ts +1 -1
- package/dist/index.js +8 -6
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -103,17 +103,18 @@ function createShortcut(keys, callback, options = {}) {
|
|
|
103
103
|
return reset = false;
|
|
104
104
|
if (reset)
|
|
105
105
|
return;
|
|
106
|
+
const e = event();
|
|
106
107
|
if (sequence2.length < keys.length) {
|
|
107
108
|
if (equalsKeyHoldSequence(sequence2, keys.slice(0, sequence2.length))) {
|
|
108
|
-
preventDefault &&
|
|
109
|
+
preventDefault && e.preventDefault();
|
|
109
110
|
} else {
|
|
110
111
|
reset = true;
|
|
111
112
|
}
|
|
112
113
|
} else {
|
|
113
114
|
reset = true;
|
|
114
115
|
if (equalsKeyHoldSequence(sequence2, keys)) {
|
|
115
|
-
preventDefault &&
|
|
116
|
-
callback();
|
|
116
|
+
preventDefault && e.preventDefault();
|
|
117
|
+
callback(e);
|
|
117
118
|
}
|
|
118
119
|
}
|
|
119
120
|
};
|
|
@@ -121,17 +122,18 @@ function createShortcut(keys, callback, options = {}) {
|
|
|
121
122
|
const last = sequence2.at(-1);
|
|
122
123
|
if (!last)
|
|
123
124
|
return;
|
|
125
|
+
const e = event();
|
|
124
126
|
if (preventDefault && last.length < keys.length) {
|
|
125
127
|
if (utils.arrayEquals(last, keys.slice(0, keys.length - 1))) {
|
|
126
|
-
|
|
128
|
+
e.preventDefault();
|
|
127
129
|
}
|
|
128
130
|
return;
|
|
129
131
|
}
|
|
130
132
|
if (utils.arrayEquals(last, keys)) {
|
|
131
133
|
const prev = sequence2.at(-2);
|
|
132
134
|
if (!prev || utils.arrayEquals(prev, keys.slice(0, keys.length - 1))) {
|
|
133
|
-
preventDefault &&
|
|
134
|
-
callback();
|
|
135
|
+
preventDefault && e.preventDefault();
|
|
136
|
+
callback(e);
|
|
135
137
|
}
|
|
136
138
|
}
|
|
137
139
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -112,7 +112,7 @@ declare function createKeyHold(key: KbdKey, options?: {
|
|
|
112
112
|
* });
|
|
113
113
|
* ```
|
|
114
114
|
*/
|
|
115
|
-
declare function createShortcut(keys: KbdKey[], callback:
|
|
115
|
+
declare function createShortcut(keys: KbdKey[], callback: (event: KeyboardEvent) => void, options?: {
|
|
116
116
|
preventDefault?: boolean;
|
|
117
117
|
requireReset?: boolean;
|
|
118
118
|
}): void;
|
package/dist/index.js
CHANGED
|
@@ -101,17 +101,18 @@ function createShortcut(keys, callback, options = {}) {
|
|
|
101
101
|
return reset = false;
|
|
102
102
|
if (reset)
|
|
103
103
|
return;
|
|
104
|
+
const e = event();
|
|
104
105
|
if (sequence2.length < keys.length) {
|
|
105
106
|
if (equalsKeyHoldSequence(sequence2, keys.slice(0, sequence2.length))) {
|
|
106
|
-
preventDefault &&
|
|
107
|
+
preventDefault && e.preventDefault();
|
|
107
108
|
} else {
|
|
108
109
|
reset = true;
|
|
109
110
|
}
|
|
110
111
|
} else {
|
|
111
112
|
reset = true;
|
|
112
113
|
if (equalsKeyHoldSequence(sequence2, keys)) {
|
|
113
|
-
preventDefault &&
|
|
114
|
-
callback();
|
|
114
|
+
preventDefault && e.preventDefault();
|
|
115
|
+
callback(e);
|
|
115
116
|
}
|
|
116
117
|
}
|
|
117
118
|
};
|
|
@@ -119,17 +120,18 @@ function createShortcut(keys, callback, options = {}) {
|
|
|
119
120
|
const last = sequence2.at(-1);
|
|
120
121
|
if (!last)
|
|
121
122
|
return;
|
|
123
|
+
const e = event();
|
|
122
124
|
if (preventDefault && last.length < keys.length) {
|
|
123
125
|
if (arrayEquals(last, keys.slice(0, keys.length - 1))) {
|
|
124
|
-
|
|
126
|
+
e.preventDefault();
|
|
125
127
|
}
|
|
126
128
|
return;
|
|
127
129
|
}
|
|
128
130
|
if (arrayEquals(last, keys)) {
|
|
129
131
|
const prev = sequence2.at(-2);
|
|
130
132
|
if (!prev || arrayEquals(prev, keys.slice(0, keys.length - 1))) {
|
|
131
|
-
preventDefault &&
|
|
132
|
-
callback();
|
|
133
|
+
preventDefault && e.preventDefault();
|
|
134
|
+
callback(e);
|
|
133
135
|
}
|
|
134
136
|
}
|
|
135
137
|
};
|
package/package.json
CHANGED