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