skip to Main Content

Does HTML have a Javascript Listener for holding/touching down on an element?

I'm working on a little app, where I go left while holding on a text/button. HTML: <h1 style="color:white;" id="goLeft">Left</h1> JS: document.querySelector('#goLeft').addEventListener('touchstart', function(){ simulateKeyDown('a') }) document.querySelector('#goLeft').addEventListener('mousedown', function(){ simulateKeyDown('a') }) document.querySelector('#goLeft').addEventListener('touchstop', function(){ simulateKeyUp('a') }) document.querySelector('#goLeft').addEventListener('mouseup', function(){ simulateKeyUp('a') }) Now while that works…

VIEW QUESTION
Back To Top
Search