Skip to content

Commit

Permalink
Merge KeyboardEvent/MouseEvent.which into UIEvent.which (#8751)
Browse files Browse the repository at this point in the history
  • Loading branch information
queengooborg authored Sep 8, 2021
1 parent 9f1dd5d commit 16e08ce
Show file tree
Hide file tree
Showing 5 changed files with 110 additions and 179 deletions.
14 changes: 8 additions & 6 deletions files/en-us/_redirects.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2024,7 +2024,7 @@
/en-US/docs/DOM/event.timeStamp /en-US/docs/Web/API/Event/timeStamp
/en-US/docs/DOM/event.type /en-US/docs/Web/API/Event/type
/en-US/docs/DOM/event.view /en-US/docs/Web/API/UIEvent/view
/en-US/docs/DOM/event.which /en-US/docs/Web/API/KeyboardEvent/which
/en-US/docs/DOM/event.which /en-US/docs/Web/API/UIEvent/which
/en-US/docs/DOM/event/AnimationEvent /en-US/docs/Web/API/AnimationEvent
/en-US/docs/DOM/event/Comparison_of_Event_Targets /en-US/docs/Web/API/Event/Comparison_of_Event_Targets
/en-US/docs/DOM/form.acceptCharset /en-US/docs/Web/API/HTMLFormElement/acceptCharset
Expand Down Expand Up @@ -2514,7 +2514,7 @@
/en-US/docs/DOM:event.timeStamp /en-US/docs/Web/API/Event/timeStamp
/en-US/docs/DOM:event.type /en-US/docs/Web/API/Event/type
/en-US/docs/DOM:event.view /en-US/docs/Web/API/UIEvent/view
/en-US/docs/DOM:event.which /en-US/docs/Web/API/KeyboardEvent/which
/en-US/docs/DOM:event.which /en-US/docs/Web/API/UIEvent/which
/en-US/docs/DOM:event:Comparison_of_Event_Targets /en-US/docs/Web/API/Event/Comparison_of_Event_Targets
/en-US/docs/DOM:form.acceptCharset /en-US/docs/Web/API/HTMLFormElement/acceptCharset
/en-US/docs/DOM:form.action /en-US/docs/Web/API/HTMLFormElement/action
Expand Down Expand Up @@ -7891,7 +7891,8 @@
/en-US/docs/Web/API/KeyboardEvent.location /en-US/docs/Web/API/KeyboardEvent/location
/en-US/docs/Web/API/KeyboardEvent.metaKey /en-US/docs/Web/API/KeyboardEvent/metaKey
/en-US/docs/Web/API/KeyboardEvent.shiftKey /en-US/docs/Web/API/KeyboardEvent/shiftKey
/en-US/docs/Web/API/KeyboardEvent.which /en-US/docs/Web/API/KeyboardEvent/which
/en-US/docs/Web/API/KeyboardEvent.which /en-US/docs/Web/API/UIEvent/which
/en-US/docs/Web/API/KeyboardEvent/which /en-US/docs/Web/API/UIEvent/which
/en-US/docs/Web/API/KeyframeEffect/KeyframeEffect.getKeyframes() /en-US/docs/Web/API/KeyframeEffect/getKeyframes
/en-US/docs/Web/API/KeyframeEffect/getFrames /en-US/docs/Web/API/KeyframeEffect/getKeyframes
/en-US/docs/Web/API/KeyframeEffect/setFrames /en-US/docs/Web/API/KeyframeEffect/setKeyframes
Expand Down Expand Up @@ -8001,9 +8002,10 @@
/en-US/docs/Web/API/MouseEvent.screenX /en-US/docs/Web/API/MouseEvent/screenX
/en-US/docs/Web/API/MouseEvent.screenY /en-US/docs/Web/API/MouseEvent/screenY
/en-US/docs/Web/API/MouseEvent.shiftKey /en-US/docs/Web/API/MouseEvent/shiftKey
/en-US/docs/Web/API/MouseEvent.which /en-US/docs/Web/API/MouseEvent/which
/en-US/docs/Web/API/MouseEvent.which /en-US/docs/Web/API/UIEvent/which
/en-US/docs/Web/API/MouseEvent/MouseEvent.WEBKIT_FORCE_AT_FORCE_MOUSE_DOWN /en-US/docs/Web/API/MouseEvent/WEBKIT_FORCE_AT_FORCE_MOUSE_DOWN
/en-US/docs/Web/API/MouseEvent/MouseEvent.WEBKIT_FORCE_AT_MOUSE_DOWN /en-US/docs/Web/API/MouseEvent/WEBKIT_FORCE_AT_MOUSE_DOWN
/en-US/docs/Web/API/MouseEvent/which /en-US/docs/Web/API/UIEvent/which
/en-US/docs/Web/API/MsAudioCategory /en-US/docs/Web/API/HTMLAudioElement/msAudioCategory
/en-US/docs/Web/API/MsAudioDeviceType /en-US/docs/Web/API/HTMLAudioElement/msAudioDeviceType
/en-US/docs/Web/API/MsClearEffects /en-US/docs/Web/API/HTMLMediaElement/msClearEffects
Expand Down Expand Up @@ -8647,7 +8649,7 @@
/en-US/docs/Web/API/UIEvent.pageX /en-US/docs/Web/API/MouseEvent/pageX
/en-US/docs/Web/API/UIEvent.pageY /en-US/docs/Web/API/MouseEvent/pageY
/en-US/docs/Web/API/UIEvent.view /en-US/docs/Web/API/UIEvent/view
/en-US/docs/Web/API/UIEvent.which /en-US/docs/Web/API/KeyboardEvent/which
/en-US/docs/Web/API/UIEvent.which /en-US/docs/Web/API/UIEvent/which
/en-US/docs/Web/API/UIEvent/UIEvent.detail /en-US/docs/Web/API/UIEvent/detail
/en-US/docs/Web/API/UIEvent/cancelBubble /en-US/docs/Web/API/Event/cancelBubble
/en-US/docs/Web/API/UIEvent/pageX /en-US/docs/Web/API/MouseEvent/pageX
Expand Down Expand Up @@ -9258,7 +9260,7 @@
/en-US/docs/Web/API/event.timeStamp /en-US/docs/Web/API/Event/timeStamp
/en-US/docs/Web/API/event.type /en-US/docs/Web/API/Event/type
/en-US/docs/Web/API/event.view /en-US/docs/Web/API/UIEvent/view
/en-US/docs/Web/API/event.which /en-US/docs/Web/API/KeyboardEvent/which
/en-US/docs/Web/API/event.which /en-US/docs/Web/API/UIEvent/which
/en-US/docs/Web/API/form.acceptCharset /en-US/docs/Web/API/HTMLFormElement/acceptCharset
/en-US/docs/Web/API/form.action /en-US/docs/Web/API/HTMLFormElement/action
/en-US/docs/Web/API/form.elements /en-US/docs/Web/API/HTMLFormElement/elements
Expand Down
33 changes: 0 additions & 33 deletions files/en-us/_wikihistory.json
Original file line number Diff line number Diff line change
Expand Up @@ -58305,26 +58305,6 @@
"teoli"
]
},
"Web/API/KeyboardEvent/which": {
"modified": "2020-10-15T21:08:46.373Z",
"contributors": [
"mfluehr",
"fscholz",
"julienw",
"libbymc",
"jwhitlock",
"cvrebert",
"teoli",
"SphinxKnight",
"kscarfone",
"Kartik_Chadha",
"Sheppy",
"Huan",
"Matej Lednar",
"Nickolay",
"Jabez"
]
},
"Web/API/KeyboardLayoutMap": {
"modified": "2020-10-15T22:08:44.841Z",
"contributors": [
Expand Down Expand Up @@ -62424,19 +62404,6 @@
"cvrebert"
]
},
"Web/API/MouseEvent/which": {
"modified": "2020-10-15T21:28:19.449Z",
"contributors": [
"mfluehr",
"fscholz",
"libbymc",
"Ac1521",
"cvrebert",
"Sebastianz",
"teoli",
"Marijn"
]
},
"Web/API/MouseEvent/x": {
"modified": "2020-10-15T21:38:31.701Z",
"contributors": [
Expand Down
86 changes: 0 additions & 86 deletions files/en-us/web/api/keyboardevent/which/index.html

This file was deleted.

54 changes: 0 additions & 54 deletions files/en-us/web/api/mouseevent/which/index.html

This file was deleted.

102 changes: 102 additions & 0 deletions files/en-us/web/api/uievent/which/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
---
title: UIEvent.which
slug: Web/API/UIEvent/which
tags:
- API
- DOM
- UIEvent
- Property
- Read-only
- Reference
browser-compat: api.UIEvent.which
---
<div>{{ APIRef("DOM Events") }} {{Non-standard_header}}</div>

<p>The <code><strong>UIEvent.which</strong></code> read-only property of the {{domxref("UIEvent")}}
interface returns a number that indicates which button was pressed on the mouse, or the
numeric <code>keyCode</code> or the character code (<code>charCode</code>) of the key
pressed on the keyboard.</p>

<h2 id="Syntax">Syntax</h2>

<pre class="brush: js notranslate">var <em>result</em> = <em>event</em>.which;
</pre>

<h3 id="Return_value">Return value</h3>

<h4 id="Return_value_KeyboardEvent">Return value for {{domxref("KeyboardEvent")}}</h4>

<ul>
<li><code>event.which</code> contains the numeric code for a particular key pressed,
depending on whether an alphanumeric or non-alphanumeric key was pressed. Please see
{{domxref("KeyboardEvent.charCode")}} and {{domxref("KeyboardEvent.keyCode")}} for
more details.</li>
</ul>

<h4 id="Return_value_MouseEvent">Return value for {{domxref("MouseEvent")}} {{non-standard_inline}}</h4>

<p>A number representing a given button:</p>

<ul>
<li><code>0</code>: No button</li>
<li><code>1</code>: Left button</li>
<li><code>2</code>: Middle button (if present)</li>
<li><code>3</code>: Right button</li>
</ul>

<p>For a mouse configured for left-handed use, the button actions are reversed. In this
case, the values are read from right to left.</p>

<h2 id="Example">Example</h2>

<pre class="brush: html">&lt;html&gt;
&lt;head&gt;
&lt;title&gt;charCode/keyCode/which example&lt;/title&gt;

&lt;script type="text/javascript"&gt;

function showKeyPress(evt) {
alert("onkeypress handler: \n"
+ "keyCode property: " + evt.keyCode + "\n"
+ "which property: " + evt.which + "\n"
+ "charCode property: " + evt.charCode + "\n"
+ "Character Key Pressed: "
+ String.fromCharCode(evt.charCode) + "\n"
);
}

function keyDown(evt) {
alert("onkeydown handler: \n"
+ "keyCode property: " + evt.keyCode + "\n"
+ "which property: " + evt.which + "\n"
);
}

&lt;/script&gt;
&lt;/head&gt;

&lt;body
onkeypress="showKeyPress(event);"
onkeydown="keyDown(event);"
&gt;

&lt;p&gt;Please press any key.&lt;/p&gt;

&lt;/body&gt;
&lt;/html&gt;
</pre>

<h2 id="Specifications">Specifications</h2>

{{Specifications}}

<h2 id="Browser_compatibility">Browser compatibility</h2>

<p>{{Compat}}</p>

<h2 id="See_also">See also</h2>

<ul>
<li>{{domxref("KeyboardEvent")}}</li>
<li>{{domxref("MouseEvent")}}</li>
</ul>

0 comments on commit 16e08ce

Please sign in to comment.