Īpašība event.ctrlKey

Īpašība event.ctrlKey ļauj uzzināt, vai notikuma laikā ir nospiests taustiņš Ctrl.

Sintakse

javascriptevent.ctrlKey;

Piemērs

Šajā piemērā, noklikšķinot uz pogas, tiks izvadīts ziņojums par to, vai ir nospiests viens no taustiņiem Ctrl, Alt vai Shift:

html<button id="button">click me</button>
javascriptlet button = document.querySelector('#button');

button.addEventListener('click', function(event) {
  if (event.ctrlKey) {
    alert('nospiests Ctrl');
  }
  
  if (event.altKey) {
    alert('nospiests Alt');
  }
  
  if (event.shiftKey) {
    alert('nospiests Shift');
  }
});

Результат:

Skatiet arī