Latest web development tutorials

ctrlKey event properties

Event Object Reference Event objects

Definition and Usage

ctrlKey Events property returns a Boolean value that indicates when the event occurred, Ctrl key is pressed and hold.

grammar

event.ctrlKey=true|false|1|0


Examples

Examples

The following example prompts when the mouse button is clicked "CTRL" key is held down:

<! DOCTYPE html>
<Html>
<Head>
<Meta charset = "utf-8">
<Title> This tutorial (w3big.com) </ title>
<Script>
function isKeyPressed (event) {
if (event.ctrlKey == 1) {
alert ( "CTRL key is pressed!");
} Else {
alert ( "CTRL key is not pressed!");
}
}
</ Script>
</ Head>
<Body onmousedown = "isKeyPressed (event)">

<P> Click somewhere in the document. An alert box will tell you whether you press the CTRL key. </ P>

</ Body>
</ Html>

try it"


Event Object Reference Event objects