Jump to content

Onkeypress


kewley

Recommended Posts

function doSomething(e) {	var code;	if (!e) var e = window.event;	if (e.keyCode) code = e.keyCode;	else if (e.which) code = e.which;	var character = String.fromCharCode(code);	if(character.toLowerCase()=="h") { alert("your message here") }}

Your body tag:<body onkeypress="doSomething(event)">Adapted from quirksmode.Choco

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...