propiedades de evento altKey
Definición y Uso
altKey atributo de evento devuelve un valor booleano. Indica cuando se produce un evento especificado, se pulsa la tecla Alt y se sostiene.
gramática
event.altKey=true|false|1|0
Ejemplos
Ejemplos
El siguiente ejemplo indica cuando se hace clic en el botón del ratón se presiona la tecla "ALT" si:
<html>
<head>
<script>
function isKeyPressed(event)
{
if (event.altKey==1)
{
alert("The ALT key was pressed!")
}
else
{
alert("The ALT key was NOT pressed!")
}
}
</script>
</head>
<body onmousedown="isKeyPressed(event)">
<p>Click somewhere in the document.
An alert box will tell you if you
pressed the ALT key or not.</p>
</body>
</html>
<head>
<script>
function isKeyPressed(event)
{
if (event.altKey==1)
{
alert("The ALT key was pressed!")
}
else
{
alert("The ALT key was NOT pressed!")
}
}
</script>
</head>
<body onmousedown="isKeyPressed(event)">
<p>Click somewhere in the document.
An alert box will tell you if you
pressed the ALT key or not.</p>
</body>
</html>
Trate »
Los objetos de evento