JSFiddle - React, Tailwind, and code Playground
by exercices
HTML
<p>
Detecter la touche "Ctrl".
</p>
JavaScript
var ctrlPressed = false;
document.onkeydown=function checkKeyDown(e){
if(e.code=="ControlLeft"||e.code=="ControlRight"){
ctrlPressed=true;
}else{ctrlPressed=false;}
};
document.onkeyup=function checkKeyUp(e){
if(e.code=="ControlLeft"||event.code=="ControlRight"){
if(ctrlPressed){alert("CTRL only pressed");}
}
};