Saiyine
Punto Com

Knowing what key has been pressed

2006-10-25 02:54:49

To get to know what key has been pressed in a web page is fairly easy. Just assign a variable to the onkeypressed event and read it, being careful to respect the diference between JScript of internet explorer and the real Javascript from other browsers. That's the meaning of the if conditional lines.

<script language="JavaScript">
<!--

document.onkeypress = keyhandler;

function keyhandler(e) {
    if (document.layers)
        Key = e.which;
    else
        Key = window.event.keyCode;
    if (Key != 0)
        alert("Key pressed! ASCII-value: " + Key);
}
//-->
</script>

Rollos antiguos

2006-10-25 02:54:05 - Saber que tecla ha sido pulsada.

2006-10-25 02:50:27 - Storing objects in PHP with serialize.

2006-10-25 02:49:52 - Guardar objetos en PHP con serialize.

2006-10-25 02:48:32 - Mejor musica que publicidad.

2006-10-25 02:46:04 - Abrir programas asociados desde la linea de comandos.

Saiyine

Selfie of meHi! Welcome to Saiyine Punto Com where I talk about anything that goes through my mind!

Puedo prometer y prometo que a la mayor brevedad aquí irá un menú o algo asín.