Key Codes

[Total: 0    Average: 0/5]

Javascript Key Codes

This document is written by Helge Willum Larsen
It contains a list of all “onkeypress”, “onkeydown” and “onkeyup” KeyCodes in JavaScript,
that can be typed with a DANISH KEYBOARD !!!
Other keyboards probably have other KeyCodes.

The first section is tested with the Microsoft Internet Explore 5.0 and the Netscape
Communicator 4.51. At this time, Netscape didn’t support “onkeydown” and “onkeyup”.

I strongly recommend that you use the “onkeypress” function.
It has the greatest browser-compatibility.
Otherwise, you can maybe use some of the codes in the bottom of the page:

if (navigator.appName == ‘Netscape’){

if (navigator.appName == ‘Microsoft Internet Explorer’){
document.onkeydown = InternetExplore; //NO “()”
if (navigator.appName != ‘Microsoft Internet Explorer’){
document.onkeypress = OtherBrowsers; //NO “()”

function InternetExplore(e){ //Remember the (e)
document.keyform.keynumber.value = window.event.keyCode;

document.keyform.keystring.value = “[ ” + String.fromCharCode(window.event.keyCode) + ” ]”;


function OtherBrowsers(e){ //Remember the (e)
document.keyform.keynumber.value = e.which;

document.keyform.keystring.value = “[ ” + String.fromCharCode(e.which) + ” ]”;





Times Viewed: 54

Leave a Reply

Your email address will not be published. Required fields are marked *