@leonabcd123/modern-caps-lock 3.1.0 → 3.1.2

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/README.md CHANGED
@@ -13,7 +13,9 @@ Modern Caps Lock provides an easy way to check whether Caps Lock is active, and
13
13
  3. [Examples](#examples)
14
14
  1. [Print Caps Lock state after every change](#print-caps-lock-state-after-every-change)
15
15
  2. [Get current Caps Lock state](#get-current-caps-lock-state)
16
- 4. [Supported Platforms](#supported-platforms)
16
+ 4. [Support](#support)
17
+ 1. [Supported Platforms](#supported-platforms)
18
+ 2. [Unsupported Platforms](#unsupported-platforms)
17
19
  5. [Limitations](#limitations)
18
20
  6. [Credits](#credits)
19
21
 
@@ -75,13 +77,19 @@ if (isCapsLockOn()) {
75
77
  }
76
78
  ```
77
79
 
78
- ### Supported Platforms
80
+ ### Support
81
+
82
+ ##### Supported Platforms
79
83
 
80
84
  - Windows
81
85
  - Mac
82
86
  - Linux
83
87
  - iPad
84
- - Android
88
+ - Platforms using GBoard
89
+
90
+ ##### Unsupported Platforms
91
+
92
+ - Platforms using Samsung keyboard
85
93
 
86
94
  ### Limitations
87
95
 
package/lib/index.js CHANGED
@@ -1,10 +1,12 @@
1
- import { getCurrentOs } from "./os-detection";
1
+ var _a, _b;
2
+ import { getCurrentOs } from "./os-detection.js";
2
3
  let previousCapsState = false;
3
4
  let capsState = false;
4
5
  const os = getCurrentOs();
5
6
  let onCapsChangeCallback;
6
7
  const mouseEventsToUpdateOn = ["mousedown", "mousemove", "wheel"];
7
- const isiPad = os === "Mac" && navigator.maxTouchPoints > 1;
8
+ const isMobile = (_b = (_a = navigator.userAgentData) === null || _a === void 0 ? void 0 : _a.mobile) !== null && _b !== void 0 ? _b : navigator.maxTouchPoints > 1;
9
+ const isiPad = os === "Mac" && isMobile;
8
10
  let isSendingCapsLockState = !isiPad;
9
11
  function callCallbackIfNeeded() {
10
12
  const callCallback = previousCapsState !== capsState;
@@ -20,8 +22,11 @@ function getCapsLockModifierState(event) {
20
22
  mouseEventsToUpdateOn.forEach((eventType) => {
21
23
  document.addEventListener(eventType, (event) => {
22
24
  if (!isiPad) {
23
- capsState = getCapsLockModifierState(event);
24
- callCallbackIfNeeded();
25
+ const currentCapsState = getCapsLockModifierState(event);
26
+ if (!isMobile || !currentCapsState) {
27
+ capsState = currentCapsState;
28
+ callCallbackIfNeeded();
29
+ }
25
30
  }
26
31
  });
27
32
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leonabcd123/modern-caps-lock",
3
- "version": "3.1.0",
3
+ "version": "3.1.2",
4
4
  "description": "A package that allows you to check whether caps lock is active or not",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",