Esempio
Scopri se il "CTRL" tasto è stato premuto quando si preme un tasto della tastiera:
var x = document.getElementById("demo");
if (event.ctrlKey) {
x.innerHTML = "The CTRL key was pressed!";
} else {
x.innerHTML = "The CTRL key was NOT pressed!";
}
Prova tu stesso " Definizione e l'utilizzo
La proprietà ctrlKey restituisce un valore booleano che indica se il "CTRL" tasto è stato premuto quando un evento chiave è stato attivato.
Nota: questa proprietà è di sola lettura.
Supporto browser
Proprietà | |||||
---|---|---|---|---|---|
ctrlKey | sì | sì | sì | sì | sì |
Sintassi
event .ctrlKey
Dettagli tecnici
Valore di ritorno: | Un valore booleano, che indica se il "CTRL" tasto è stato premuto quando l'evento chiave è verificato. Valori possibili:
|
---|---|
DOM Versione: | Livello DOM 2 Eventi |
Pagine correlate
Di riferimento HTML DOM: KeyboardEvent altKey Property
Di riferimento HTML DOM: KeyboardEvent metaKey Property
Di riferimento HTML DOM: KeyboardEvent shiftKey Property
<Oggetto evento