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