@whitesev/domutils 1.3.1 → 1.3.2
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.amd.js +4 -1
- package/dist/index.amd.js.map +1 -1
- package/dist/index.cjs.js +4 -1
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +4 -1
- package/dist/index.esm.js.map +1 -1
- package/dist/index.iife.js +4 -1
- package/dist/index.iife.js.map +1 -1
- package/dist/index.system.js +4 -1
- package/dist/index.system.js.map +1 -1
- package/dist/index.umd.js +4 -1
- package/dist/index.umd.js.map +1 -1
- package/dist/types/src/DOMUtilsEvent.d.ts +1 -1
- package/package.json +1 -1
- package/src/DOMUtilsEvent.ts +7 -4
|
@@ -571,7 +571,7 @@ export declare class DOMUtilsEvent {
|
|
|
571
571
|
搜索 170
|
|
572
572
|
收藏 171
|
|
573
573
|
**/
|
|
574
|
-
listenKeyboard(target: Window | Node | HTMLElement | typeof globalThis, eventName: ("keyup" | "keypress" | "keydown") | undefined, callback: (keyName: string, keyValue:
|
|
574
|
+
listenKeyboard(target: Window | Node | HTMLElement | typeof globalThis, eventName: ("keyup" | "keypress" | "keydown") | undefined, callback: (keyName: string, keyValue: number, otherCodeList: string[], event: KeyboardEvent) => void, options?: AddEventListenerOptions | boolean): {
|
|
575
575
|
removeListen(): void;
|
|
576
576
|
};
|
|
577
577
|
}
|
package/package.json
CHANGED
package/src/DOMUtilsEvent.ts
CHANGED
|
@@ -1325,7 +1325,7 @@ export class DOMUtilsEvent {
|
|
|
1325
1325
|
eventName: "keyup" | "keypress" | "keydown" = "keypress",
|
|
1326
1326
|
callback: (
|
|
1327
1327
|
keyName: string,
|
|
1328
|
-
keyValue:
|
|
1328
|
+
keyValue: number,
|
|
1329
1329
|
otherCodeList: string[],
|
|
1330
1330
|
event: KeyboardEvent
|
|
1331
1331
|
) => void,
|
|
@@ -1334,9 +1334,12 @@ export class DOMUtilsEvent {
|
|
|
1334
1334
|
removeListen(): void;
|
|
1335
1335
|
} {
|
|
1336
1336
|
let keyboardEventCallBack = function (event: KeyboardEvent) {
|
|
1337
|
+
/** 键名 */
|
|
1337
1338
|
let keyName = event.key || event.code;
|
|
1339
|
+
/** 键值 */
|
|
1338
1340
|
let keyValue = event.charCode || event.keyCode || event.which;
|
|
1339
|
-
|
|
1341
|
+
/** 组合键列表 */
|
|
1342
|
+
let otherCodeList: string[] = [];
|
|
1340
1343
|
if (event.ctrlKey) {
|
|
1341
1344
|
otherCodeList.push("ctrl");
|
|
1342
1345
|
}
|
|
@@ -1350,10 +1353,10 @@ export class DOMUtilsEvent {
|
|
|
1350
1353
|
otherCodeList.push("shift");
|
|
1351
1354
|
}
|
|
1352
1355
|
if (typeof callback === "function") {
|
|
1353
|
-
callback(keyName, keyValue
|
|
1356
|
+
callback(keyName, keyValue, otherCodeList, event);
|
|
1354
1357
|
}
|
|
1355
1358
|
};
|
|
1356
|
-
this.on(target, eventName, keyboardEventCallBack
|
|
1359
|
+
this.on(target, eventName, keyboardEventCallBack, options);
|
|
1357
1360
|
return {
|
|
1358
1361
|
removeListen: () => {
|
|
1359
1362
|
this.off(target, eventName, keyboardEventCallBack, options);
|