Web Platform Atlas
EN⚡RUUA⚡DE⚡FR⚡ES⚡PL⚡PT⚡ZH⚡JA⚡
Каталог / UI Events / keypress

8.3.1.1 keypress

Статический предпросмотр (RU): для MDN, WPT, глоссария и BYOK-перевода откройте интерактивный Атлас.
⚡ Открыть главу в Атласе

8.3.1.1. keypress

Тип

keypress

Интерфейс

KeyboardEvent

Синхронность / Асинхронность

Синхронно

Всплытие

Да

Доверенные цели

Element

Отменяемость

Да

Композиция

Да

Действие по умолчанию

Varies: launch text composition system; blur and focus events; DOMActivate event; other event

Context(trusted events)

Event.target : элемент в фокусе, обрабатывающий событие клавиши, или, если ни один элемент не в фокусе, элемент body (если доступен), в противном случае корневой элемент

UIEvent.view : Window

UIEvent.detail : 0

KeyboardEvent.which : legacy numerical code for this key

KeyboardEvent.charCode : legacy character value for this event

KeyboardEvent.keyCode : legacy numerical code for this key

KeyboardEvent.key : значение клавиши, которая была нажата.

KeyboardEvent.code : значение кода, связанное с физическим расположением клавиши на клавиатуре.

KeyboardEvent.location : расположение клавиши на устройстве.

KeyboardEvent.altKey : true, если модификатор Alt был активен, иначе false

KeyboardEvent.shiftKey : true, если модификатор Shift был активен, иначе false

KeyboardEvent.ctrlKey : true, если модификатор Control был активен, иначе false

KeyboardEvent.metaKey : true, если модификатор Meta был активен, иначе false

KeyboardEvent.repeat : false

KeyboardEvent.isComposing : true, если событие клавиши происходит в рамках сеанса композиции, иначе false

If supported by a user agent, this event MUST be dispatched when a key is pressed down, if and only if that key normally produces a character value. The keypress event type is device dependent and relies on the capabilities of the input devices and how they are mapped in the operating system.

This event type MUST be generated after the key mapping. It MUST NOT be fired when using an input method editor.

If this event is canceled, it should prevent the input event from firing, in addition to canceling the default action.

Authors SHOULD use the beforeinput event instead of the keypress event.

The keypress event is traditionally associated with detecting a character value rather than a physical key, and might not be available on all keys in some configurations.

The keypress event type is defined in this specification for reference and completeness, but this specification deprecates the use of this event type. When in editing contexts, authors can subscribe to the beforeinput event instead.