Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

Revision 1046608 of keypress

  • Revision slug: Web/Events/keypress
  • Revision title: keypress
  • Revision id: 1046608
  • Created:
  • Creator: Dikrib
  • Is current revision? No
  • Comment

Revision Content

The keypress event is fired when a key is pressed down and that key normally produces a character value (use input instead).

General info

Specification
DOM L3 {{deprecated_inline()}}
Interface
KeyboardEvent
Bubbles
Yes
Cancelable
Yes
Target
Document, Element
Default Action
Varies: keypress event; launch text composition system; blur and focus events; DOMActivate event; other event

Properties

{{OpenEventProperties()}}{{UIEventProperties()}}{{KeyboardEventProperties()}}{{ModifiersEventProperties()}}{{CloseEventProperties()}}

Notes

Chrome does not fire the keypress event for known keyboard shortcuts (reference). Which keyboard shortcuts are known depends on the user's system. Use the keydown event to implement keyboard shortcuts.

{{KeyRelatedEvents()}}

<style type="text/css">:visited{color:purple !important} </style> <style type="text/css">:visited{color:purple !important} </style>

Revision Source

<p>The <code>keypress</code> event is fired when a key is pressed down and that key normally produces a character value (use <a href="/en-US/Mozilla_event_reference/input"><code>input</code></a> instead).</p>

<h2 id="General_info">General info</h2>

<dl>
 <dt style="float: left; text-align: right; width: 120px;">Specification</dt>
 <dd style="margin: 0 0 0 120px;"><a class="external" href="https://www.w3.org/TR/DOM-Level-3-Events/#event-type-keypress">DOM L3</a> {{deprecated_inline()}}</dd>
 <dt style="float: left; text-align: right; width: 120px;">Interface</dt>
 <dd style="margin: 0 0 0 120px;"><a href="/en-US/docs/DOM/KeyboardEvent" title="https://en-US/docs/DOM/KeyboardEvent">KeyboardEvent</a></dd>
 <dt style="float: left; text-align: right; width: 120px;">Bubbles</dt>
 <dd style="margin: 0 0 0 120px;">Yes</dd>
 <dt style="float: left; text-align: right; width: 120px;">Cancelable</dt>
 <dd style="margin: 0 0 0 120px;">Yes</dd>
 <dt style="float: left; text-align: right; width: 120px;">Target</dt>
 <dd style="margin: 0 0 0 120px;">Document, Element</dd>
 <dt style="float: left; text-align: right; width: 120px;">Default Action</dt>
 <dd style="margin: 0 0 0 120px;">Varies: <code>keypress</code> event; launch text composition system; <code>blur</code> and <code>focus</code> events; <code>DOMActivate</code> event; other event</dd>
</dl>

<h2 id="Properties">Properties</h2>

<p>{{OpenEventProperties()}}{{UIEventProperties()}}{{KeyboardEventProperties()}}{{ModifiersEventProperties()}}{{CloseEventProperties()}}</p>

<h2>Notes</h2>

<p>Chrome does not fire the <code>keypress</code> event for known keyboard shortcuts (<a href="https://bugs.chromium.org/p/chromium/issues/detail?id=13891#c50">reference</a>). Which keyboard shortcuts are known depends on the user's system. Use the <code>keydown</code> event to implement keyboard shortcuts.</p>

<h2 id="Related_Events">Related Events</h2>

<p>{{KeyRelatedEvents()}}</p>
<style type="text/css">:visited{color:purple !important}
</style>
<style type="text/css">:visited{color:purple !important}
</style>
Revert to this revision