In Chrome, it works the first time, and in Firefox from the 2nd time, why? How can I fix this so that in all browsers it works the first time?
$(document).on('keyup', function( event ) { if(event.keyCode === 27) { alert('Esc key pressed.'); } }); In Chrome, it works the first time, and in Firefox from the 2nd time, why? How can I fix this so that in all browsers it works the first time?
$(document).on('keyup', function( event ) { if(event.keyCode === 27) { alert('Esc key pressed.'); } }); Try:
$(document).keypress(function( event ) { if((event.keyCode ? event.keyCode : event.which) == 27) { alert('Esc key pressed.'); return false; } }); https://stackoverflow.com/questions/7996449/jquery-keyup-working-in-all-browsers-except-firefox
Source: https://ru.stackoverflow.com/questions/607789/
All Articles