« Volver al inicio

Detecta la tecla
pulsada y su
código.

Para probar este script
en Netscape, primero pincha
aquí.
En Explorer no hace falta.

Pulsa una tecla.

Código fuente
<html>
<head>
<script>
/*******************************
Detecta la tecla pulsada. carlosbernad@teleline.es
Si usas este script, deja intactas estas líneas (créditos). Vale?
También te agradecería un e-mail con tus comentarios.
*******************************/

if (document.layers) document.captureEvents(Event.KEYPRESS)
document.onkeypress = mostrar

function mostrar(e) {

if(!e)e = window.event
letra = (!document.all)?String.fromCharCode(e.which):String.fromCharCode(e.keyCode)
alert("Ha pulsado la letra: "+letra)
return
}

</script>
<body>
Pulsa una tecla.
</body>
</html>