Jump to content

Press Esc Key after X seconds


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")

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




may this will help you

Link to comment
Share on other sites

This thread is more than a year old. Are you sure you have something important to add to it?

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • 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.