Jump to content

Press Esc Key after X seconds


seany123

Recommended Posts

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.