seany123 Posted July 18, 2013 Share Posted July 18, 2013 Hello, is it possible in javascript to press the EscKey after X seconds of website being loaded? How would this be done? thanks seany Quote Link to comment https://forums.phpfreaks.com/topic/280291-press-esc-key-after-x-seconds/ Share on other sites More sharing options...
PravinS Posted July 19, 2013 Share Posted July 19, 2013 yes it can be done, try this functions function loadsite(e) { if (!e) e = window.event; if (e.keyCode) { if (e.keyCode == "27") { setTimeout('openurl()',10000); } } } function openurl() { window.location.href = 'SITE_URL'; } first function is to check key code and if key is ESC key, then after some time interval(10000 = 10 seconds) it will call openurl() function, which is given next function now write below given code at the end of the page, it will check the key event and will call the loadsite() function document.onkeydown = loadsite; also you can check setTimout function reference here http://www.w3schools.com/jsref/met_win_settimeout.asp may this will help you Quote Link to comment https://forums.phpfreaks.com/topic/280291-press-esc-key-after-x-seconds/#findComment-1441332 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.