@whitesev/utils 2.1.5 → 2.2.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.amd.js CHANGED
@@ -3551,7 +3551,7 @@ define((function () { 'use strict';
3551
3551
  this.windowApi = new WindowApi(option);
3552
3552
  }
3553
3553
  /** 版本号 */
3554
- version = "2024.7.24";
3554
+ version = "2024.8.30";
3555
3555
  addStyle(cssText) {
3556
3556
  if (typeof cssText !== "string") {
3557
3557
  throw new Error("Utils.addStyle 参数cssText 必须为String类型");
@@ -5029,39 +5029,6 @@ define((function () { 'use strict';
5029
5029
  });
5030
5030
  return result;
5031
5031
  }
5032
- listenKeyboard(target, eventName = "keypress", callback, options) {
5033
- if (typeof target !== "object" ||
5034
- (typeof target["addEventListener"] !== "function" &&
5035
- typeof target["removeEventListener"] !== "function")) {
5036
- throw new Error("Utils.listenKeyboard 参数 target 必须为 Window|HTMLElement 类型");
5037
- }
5038
- let keyEvent = function (event) {
5039
- let keyName = event.key || event.code;
5040
- let keyValue = event.charCode || event.keyCode || event.which;
5041
- let otherCodeList = [];
5042
- if (event.ctrlKey) {
5043
- otherCodeList.push("ctrl");
5044
- }
5045
- if (event.altKey) {
5046
- otherCodeList.push("alt");
5047
- }
5048
- if (event.metaKey) {
5049
- otherCodeList.push("meta");
5050
- }
5051
- if (event.shiftKey) {
5052
- otherCodeList.push("shift");
5053
- }
5054
- if (typeof callback === "function") {
5055
- callback(keyName, keyValue.toString(), otherCodeList, event);
5056
- }
5057
- };
5058
- target.addEventListener(eventName, keyEvent, options);
5059
- return {
5060
- removeListen() {
5061
- target.removeEventListener(eventName, keyEvent);
5062
- },
5063
- };
5064
- }
5065
5032
  /**
5066
5033
  * 自动锁对象,用于循环判断运行的函数,在循环外new后使用,注意,如果函数内部存在异步操作,需要使用await
5067
5034
  * @example