diff options
Diffstat (limited to 'js/inknswitch/ink.js')
-rw-r--r-- | js/inknswitch/ink.js | 27 |
1 files changed, 13 insertions, 14 deletions
diff --git a/js/inknswitch/ink.js b/js/inknswitch/ink.js index cd0c540..73f16e5 100644 --- a/js/inknswitch/ink.js +++ b/js/inknswitch/ink.js @@ -160,21 +160,20 @@ document.addEventListener('keydown', (e) => { localStorage.setItem('noteContent', noteArea.value); }); -let touchStartTimestamp; -let touchStartCount; - -document.addEventListener('touchstart', function(e) { - touchStartTimestamp = Date.now(); - touchStartCount = e.touches.length; - if (touchStartCount === 2) { - // Check if the touches are on either side of the screen - const touch1 = e.touches[0]; - const touch2 = e.touches[1]; - const screenWidth = window.innerWidth; - if ((touch1.clientX < screenWidth / 2 && touch2.clientX > screenWidth / 2) || - (touch2.clientX < screenWidth / 2 && touch1.clientX > screenWidth / 2)) { - // The touches are on either side of the screen +let lastTap = 0; +let tapCount = 0; + +document.addEventListener('touchend', function(e) { + const currentTime = Date.now(); + const tapInterval = currentTime - lastTap; + if (tapInterval < 500 && tapInterval > 0) { + tapCount++; + if (tapCount === 3) { toggleMode(); + tapCount = 0; } + } else { + tapCount = 1; } + lastTap = currentTime; }, false); \ No newline at end of file |