Īpašība event.altKey

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

Sintakse

javascriptevent.altKey;

Piemērs

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

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ī