@whitesev/utils 2.1.4 → 2.1.5
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 +2 -2
- package/dist/index.amd.js.map +1 -1
- package/dist/index.cjs.js +2 -2
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +2 -2
- package/dist/index.esm.js.map +1 -1
- package/dist/index.iife.js +2 -2
- package/dist/index.iife.js.map +1 -1
- package/dist/index.system.js +2 -2
- package/dist/index.system.js.map +1 -1
- package/dist/index.umd.js +2 -2
- package/dist/index.umd.js.map +1 -1
- package/dist/types/src/Utils.d.ts +2 -1
- package/package.json +1 -1
- package/src/Utils.ts +7 -3
|
@@ -950,6 +950,7 @@ declare class Utils {
|
|
|
950
950
|
* @param target 需要监听的对象,可以是全局Window或者某个元素
|
|
951
951
|
* @param eventName 事件名,默认keypress
|
|
952
952
|
* @param callback 自己定义的回调事件,参数1为当前的key,参数2为组合按键,数组类型,包含ctrl、shift、alt和meta(win键或mac的cmd键)
|
|
953
|
+
* @param options 监听事件的配置
|
|
953
954
|
* @example
|
|
954
955
|
Utils.listenKeyboard(window,(keyName,keyValue,otherKey,event)=>{
|
|
955
956
|
if(keyName === "Enter"){
|
|
@@ -1006,7 +1007,7 @@ declare class Utils {
|
|
|
1006
1007
|
搜索 170
|
|
1007
1008
|
收藏 171
|
|
1008
1009
|
**/
|
|
1009
|
-
listenKeyboard(target: Window | Node | HTMLElement | typeof globalThis, eventName: "keyup" | "keypress" | "keydown", callback: (keyName: string, keyValue: string, otherCodeList: string[], event: KeyboardEvent) => void): {
|
|
1010
|
+
listenKeyboard(target: Window | Node | HTMLElement | typeof globalThis, eventName: "keyup" | "keypress" | "keydown", callback: (keyName: string, keyValue: string, otherCodeList: string[], event: KeyboardEvent) => void, options?: AddEventListenerOptions | boolean): {
|
|
1010
1011
|
removeListen(): void;
|
|
1011
1012
|
};
|
|
1012
1013
|
/**
|
package/package.json
CHANGED
package/src/Utils.ts
CHANGED
|
@@ -2309,6 +2309,7 @@ class Utils {
|
|
|
2309
2309
|
* @param target 需要监听的对象,可以是全局Window或者某个元素
|
|
2310
2310
|
* @param eventName 事件名,默认keypress
|
|
2311
2311
|
* @param callback 自己定义的回调事件,参数1为当前的key,参数2为组合按键,数组类型,包含ctrl、shift、alt和meta(win键或mac的cmd键)
|
|
2312
|
+
* @param options 监听事件的配置
|
|
2312
2313
|
* @example
|
|
2313
2314
|
Utils.listenKeyboard(window,(keyName,keyValue,otherKey,event)=>{
|
|
2314
2315
|
if(keyName === "Enter"){
|
|
@@ -2373,7 +2374,8 @@ class Utils {
|
|
|
2373
2374
|
keyValue: string,
|
|
2374
2375
|
otherCodeList: string[],
|
|
2375
2376
|
event: KeyboardEvent
|
|
2376
|
-
) => void
|
|
2377
|
+
) => void,
|
|
2378
|
+
options?: AddEventListenerOptions | boolean
|
|
2377
2379
|
): {
|
|
2378
2380
|
removeListen(): void;
|
|
2379
2381
|
};
|
|
@@ -2385,7 +2387,8 @@ class Utils {
|
|
|
2385
2387
|
keyValue: string,
|
|
2386
2388
|
otherCodeList: string[],
|
|
2387
2389
|
event: KeyboardEvent
|
|
2388
|
-
) => void
|
|
2390
|
+
) => void,
|
|
2391
|
+
options?: AddEventListenerOptions | boolean
|
|
2389
2392
|
): {
|
|
2390
2393
|
removeListen(): void;
|
|
2391
2394
|
} {
|
|
@@ -2418,7 +2421,8 @@ class Utils {
|
|
|
2418
2421
|
callback(keyName, keyValue.toString(), otherCodeList, event);
|
|
2419
2422
|
}
|
|
2420
2423
|
};
|
|
2421
|
-
|
|
2424
|
+
|
|
2425
|
+
target.addEventListener(eventName, keyEvent as any, options);
|
|
2422
2426
|
return {
|
|
2423
2427
|
removeListen() {
|
|
2424
2428
|
target.removeEventListener(eventName, keyEvent as any);
|