user experience design and consulting

Displaying the ASCII value for a pressed key

This page will display the ASCII value of any pressed key.

How to see the demo

Press a key.

Note: Key combinations that are assigned to an action in your browser will not display their value.


function showKey() {
var key = event.keyCode;
alert("You pressed: " + key + ".");

<body onKeyPress="showKey()">

How it works

This script uses the onKeyPress event to read the pressed keys and they keyCode event to convert them to ASCII values.

Browser compatibility

This script should work in any browser, but some browsers (i.e., Safari) may report unusual information. Reserved key combinations will not display a value. For more information, see the quirksmode website.


Just send us an email.