JavaScript

Keyboard events (keydown)

Në shqip: Ngjarjet e tastierës

ShpjegimiSQ

keydown ndodh kur shtypet një tast, keyup kur lëshohet. e.key të tregon cili tast ("Enter", "ArrowUp", "a"), dhe e.ctrlKey/e.metaKey nëse mbahet Ctrl ose Cmd.

EnglishEN

keydown fires when a key is pressed, keyup when it's released. e.key tells you which key ("Enter", "ArrowUp", "a"), and e.ctrlKey/e.metaKey whether Ctrl or Cmd is held.

Si ta mendosh

Si një piano që e di cilin çelës shtype.

Lexoje në anglisht

Like a piano that knows which key you pressed.

Shembull kodijavascript

document.addEventListener("keydown", (e) => {
  if (e.key === "/" ) { e.preventDefault(); kerkimi.focus(); }
  if (e.key === "Escape") mbyll();
});

Terma të lidhur