@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.
@@ -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: string, otherCodeList: string[], event: KeyboardEvent) => void, options?: AddEventListenerOptions | boolean): {
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@whitesev/domutils",
3
- "version": "1.3.1",
3
+ "version": "1.3.2",
4
4
  "description": "使用js重新对jQuery的部分函数进行了仿写",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/index.esm.js",
@@ -1325,7 +1325,7 @@ export class DOMUtilsEvent {
1325
1325
  eventName: "keyup" | "keypress" | "keydown" = "keypress",
1326
1326
  callback: (
1327
1327
  keyName: string,
1328
- keyValue: string,
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
- let otherCodeList = [];
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.toString(), otherCodeList, event);
1356
+ callback(keyName, keyValue, otherCodeList, event);
1354
1357
  }
1355
1358
  };
1356
- this.on(target, eventName, keyboardEventCallBack as any, options);
1359
+ this.on(target, eventName, keyboardEventCallBack, options);
1357
1360
  return {
1358
1361
  removeListen: () => {
1359
1362
  this.off(target, eventName, keyboardEventCallBack, options);