From 215e4fe52d774461cc17eb5508eb33a39c7303f6 Mon Sep 17 00:00:00 2001 From: elioat Date: Fri, 12 Jan 2024 22:18:33 -0500 Subject: * --- js/inknswitch/ink.js | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) (limited to 'js/inknswitch') 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 -- cgit 1.4.1-2-gfad0