Właściwości zdarzeń altKey
Definicja i Wykorzystanie
altKey atrybut zdarzenia zwraca wartość logiczną. Podać w przypadku wystąpienia określonego zdarzenia, naciśnięciu klawisza Alt i pomieścić.
gramatyka
event.altKey=true|false|1|0
Przykłady
Przykłady
Poniższy przykład wyświetla monit, gdy przycisk myszy kliknięciu klawisza "Alt" jest wciśnięty, czy:
<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>
Spróbuj »
obiekty zdarzeń