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