Snippet: js detect which key was pressed

For compatible with both IE and Mozilla


var code = (e.keyCode ? e.keyCode : e.which);
if(code == 13) { //Enter keycode
//Do something
}

One thought on “Snippet: js detect which key was pressed

  1. Attractive component of content. I just stumbled upon your web site and in accession capital to assert that I get actually
    loved account your blog posts. Anyway I will be subscribing to your feeds and even I success you access persistently rapidly.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s