diff options
| author | Peter Bengtsson <mail@peterbe.com> | 2020-12-08 14:41:45 -0500 |
|---|---|---|
| committer | Peter Bengtsson <mail@peterbe.com> | 2020-12-08 14:41:45 -0500 |
| commit | 1109132f09d75da9a28b649c7677bb6ce07c40c0 (patch) | |
| tree | 0dd8b084480983cf9f9680e8aedb92782a921b13 /files/es/web/api/mouseevent | |
| parent | 4b1a9203c547c019fc5398082ae19a3f3d4c3efe (diff) | |
| download | translated-content-1109132f09d75da9a28b649c7677bb6ce07c40c0.tar.gz translated-content-1109132f09d75da9a28b649c7677bb6ce07c40c0.tar.bz2 translated-content-1109132f09d75da9a28b649c7677bb6ce07c40c0.zip | |
initial commit
Diffstat (limited to 'files/es/web/api/mouseevent')
| -rw-r--r-- | files/es/web/api/mouseevent/index.html | 298 | ||||
| -rw-r--r-- | files/es/web/api/mouseevent/initmouseevent/index.html | 60 | ||||
| -rw-r--r-- | files/es/web/api/mouseevent/shiftkey/index.html | 126 |
3 files changed, 484 insertions, 0 deletions
diff --git a/files/es/web/api/mouseevent/index.html b/files/es/web/api/mouseevent/index.html new file mode 100644 index 0000000000..74aabe922e --- /dev/null +++ b/files/es/web/api/mouseevent/index.html @@ -0,0 +1,298 @@ +--- +title: MouseEvent +slug: Web/API/MouseEvent +tags: + - API +translation_of: Web/API/MouseEvent +--- +<p id="Summary">{{APIRef("DOM Events")}}</p> + +<p>The <code><strong>MouseEvent</strong></code> interface represents events that occur due to the user interacting with a pointing device (such as a mouse). Common events using this interface include {{event("click")}}, {{event("dblclick")}}, {{event("mouseup")}}, {{event("mousedown")}}.</p> + +<p><code>MouseEvent</code> derives from {{domxref("UIEvent")}}, which in turn derives from {{domxref("Event")}}. Though the {{domxref("MouseEvent.initMouseEvent()")}} method is kept for backward compatibility, creating of a <code>MouseEvent</code> object should be done using the {{domxref("MouseEvent.MouseEvent", "MouseEvent()")}} constructor.</p> + +<p>Several more specific events derivate from <code>MouseEvent</code>: {{domxref("WheelEvent")}} and {{domxref("DragEvent")}}.</p> + +<h2 id="Constructor">Constructor</h2> + +<dl> + <dt>{{domxref("MouseEvent.MouseEvent", "MouseEvent()")}}</dt> + <dd>Creates a <code>MouseEvent</code> object.</dd> +</dl> + +<h2 id="Properties">Properties</h2> + +<p><em>This interface also inherits properties of its parents, {{domxref("UIEvent")}} and {{domxref("Event")}}.</em></p> + +<dl> + <dt>{{domxref("MouseEvent.altKey")}} {{readonlyinline}}</dt> + <dd>Returns <code>true</code> if the <kbd>alt</kbd> key was down when the mouse event was fired.</dd> + <dt>{{domxref("MouseEvent.button")}} {{readonlyinline}}</dt> + <dd>The button number that was pressed when the mouse event was fired. </dd> + <dt>{{domxref("MouseEvent.buttons")}} {{readonlyinline}} {{gecko_minversion_inline("15.0")}}</dt> + <dd> + <p>The buttons being pressed when the mouse event was fired</p> + </dd> + <dt>{{domxref("MouseEvent.clientX")}} {{readonlyinline}}</dt> + <dd>The X coordinate of the mouse pointer in local (DOM content) coordinates.</dd> + <dt>{{domxref("MouseEvent.clientY")}} {{readonlyinline}}</dt> + <dd>The Y coordinate of the mouse pointer in local (DOM content) coordinates.</dd> + <dt>{{domxref("MouseEvent.ctrlKey")}} {{readonlyinline}}</dt> + <dd>Returns <code>true</code> if the <kbd>control</kbd> key was down when the mouse event was fired.</dd> + <dt>{{domxref("MouseEvent.metaKey")}} {{readonlyinline}}</dt> + <dd>Returns <code>true</code> if the <kbd>meta</kbd> key was down when the mouse event was fired.</dd> + <dt>{{domxref("MouseEvent.movementX")}} {{readonlyinline}}</dt> + <dd>The X coordinate of the mouse pointer relative to the position of the last {{event("mousemove")}} event.</dd> + <dt>{{domxref("MouseEvent.movementY")}} {{readonlyinline}}</dt> + <dd>The Y coordinate of the mouse pointer relative to the position of the last {{event("mousemove")}} event.</dd> + <dt>{{domxref("MouseEvent.region")}} {{readonlyinline}}</dt> + <dd>Returns the id of the hit region affected by the event. If no hit region is affected, <code>null</code> is returned.</dd> + <dt>{{domxref("MouseEvent.relatedTarget")}} {{readonlyinline}}</dt> + <dd> + <p>The secondary target for the event, if there is one.</p> + </dd> + <dt>{{domxref("MouseEvent.screenX")}} {{readonlyinline}}</dt> + <dd>The X coordinate of the mouse pointer in global (screen) coordinates.</dd> + <dt>{{domxref("MouseEvent.screenY")}} {{readonlyinline}}</dt> + <dd>The Y coordinate of the mouse pointer in global (screen) coordinates.</dd> + <dt>{{domxref("MouseEvent.shiftKey")}} {{readonlyinline}}</dt> + <dd>Returns <code>true</code> if the <kbd>shift</kbd> key was down when the mouse event was fired.</dd> + <dt>{{domxref("MouseEvent.which")}} {{non-standard_inline}} {{readonlyinline}}</dt> + <dd>The button being pressed when the mouse event was fired.</dd> + <dt>{{domxref("MouseEvent.mozPressure")}} {{non-standard_inline()}} {{readonlyinline}}</dt> + <dd>The amount of pressure applied to a touch or tablet device when generating the event; this value ranges between <code>0.0</code> (minimum pressure) and <code>1.0</code> (maximum pressure).</dd> + <dt>{{domxref("MouseEvent.mozInputSource")}} {{non-standard_inline()}} {{readonlyinline}}</dt> + <dd> + <p>The type of device that generated the event (one of the <code>MOZ_SOURCE_*</code> constants listed below). This lets you, for example, determine whether a mouse event was generated by an actual mouse or by a touch event (which might affect the degree of accuracy with which you interpret the coordinates associated with the event). The possible values are:</p> + + <table class="standard-table"> + <tbody> + <tr> + <th>Constant name</th> + <th>Value</th> + <th>Desription</th> + </tr> + <tr> + <td><code>MouseEvent.MOZ_SOURCE_UNKNOWN</code></td> + <td>0</td> + <td>The input device is unknown.</td> + </tr> + <tr> + <td><code><code>MouseEvent.</code>MOZ_SOURCE_MOUSE</code></td> + <td>1</td> + <td>The event was generated by a mouse (or mouse-like device).</td> + </tr> + <tr> + <td><code><code>MouseEvent.</code>MOZ_SOURCE_PEN</code></td> + <td>2</td> + <td>The event was generated by a pen on a tablet.</td> + </tr> + <tr> + <td><code><code>MouseEvent.</code>MOZ_SOURCE_ERASER</code></td> + <td>3</td> + <td>The event was generated by an eraser on a tablet.</td> + </tr> + <tr> + <td><code><code>MouseEvent.</code>MOZ_SOURCE_CURSOR</code></td> + <td>4</td> + <td>The event was generated by a cursor.</td> + </tr> + <tr> + <td><code><code>MouseEvent.</code>MOZ_SOURCE_TOUCH</code></td> + <td>5</td> + <td>The event was generated on a touch interface.</td> + </tr> + <tr> + <td><code><code>MouseEvent.</code>MOZ_SOURCE_KEYBOARD</code></td> + <td>6</td> + <td>The event was generated by a keyboard.</td> + </tr> + </tbody> + </table> + </dd> +</dl> + +<h2 id="Methods">Methods</h2> + +<p><em>This interface also inherits methods of its parents, {{domxref("UIEvent")}} and {{domxref("Event")}}.</em></p> + +<dl> + <dt>{{domxref("MouseEvent.getModifierState()")}}</dt> + <dd>Returns the current state of the specified modifier key. See the {{domxref("KeyboardEvent.getModifierState")}}() for details.</dd> + <dt>{{domxref("MouseEvent.initMouseEvent()")}} {{deprecated_inline}}</dt> + <dd>Initializes the value of a <code>MouseEvent</code> created. If the event has already being dispatched, this method does nothing.</dd> +</dl> + +<h2 id="Example">Example</h2> + +<p>This example demonstrates simulating a click (that is programmatically generating a click event) on a checkbox using DOM methods. </p> + +<pre class="brush: js">function simulateClick() { + var evt = new <a href="/en-US/docs/Web/API/MouseEvent">MouseEvent</a>("click", { + bubbles: true, + cancelable: true, + view: window, + }); + var cb = document.getElementById("checkbox"); //element to click on + var canceled = !cb.<a href="/en-US/docs/Web/API/EventTarget.dispatchEvent" rel="internal" title="en/DOM/element.dispatchEvent">dispatchEvent</a>(evt); + if(canceled) { + // A handler called preventDefault + alert("canceled"); + } else { + // None of the handlers called preventDefault + alert("not canceled"); + } +} +document.getElementById("button").addEventListener('click', simulateClick);</pre> + +<pre class="brush: html"><p><label><input type="checkbox" id="checkbox"> Checked</label> +<p><button id="button">Click me</button></pre> + +<p>Click on the button to see how the sample works:</p> + +<p>{{ EmbedLiveSample('Example', '', '', '') }}</p> + +<h2 id="Specifications">Specifications</h2> + +<table class="standard-table"> + <tbody> + <tr> + <th scope="col">Specification</th> + <th scope="col">Status</th> + <th scope="col">Comment</th> + </tr> + <tr> + <td>{{SpecName("HTML WHATWG", "#dom-mouseevent-region", "MouseEvent.region")}}</td> + <td>{{Spec2('HTML WHATWG')}}</td> + <td>From {{SpecName('DOM3 Events')}}, added the <code>region</code> property.</td> + </tr> + <tr> + <td>{{SpecName('Pointer Lock','#extensions-to-the-mouseevent-interface','MouseEvent')}}</td> + <td>{{Spec2('Pointer Lock')}}</td> + <td>From {{SpecName('DOM3 Events')}}, added <code>movementX</code> and <code>movementY</code> properties.</td> + </tr> + <tr> + <td>{{SpecName('DOM3 Events','#events-mouseevents','MouseEvent')}}</td> + <td>{{Spec2('DOM3 Events')}}</td> + <td>From {{SpecName('DOM2 Events')}}, added the <code>MouseEvent()</code> constructor, the <code>getModifierState()</code> method and the <code>buttons</code> property.</td> + </tr> + <tr> + <td>{{SpecName('DOM2 Events','#Events-MouseEvent','MouseEvent')}}</td> + <td>{{Spec2('DOM2 Events')}}</td> + <td>Initial definition.</td> + </tr> + </tbody> +</table> + +<h2 id="Browser_compatibility" name="Browser_compatibility">Browser compatibility</h2> + +<p>{{ CompatibilityTable() }}</p> + +<div id="compat-desktop"> +<table class="compat-table"> + <tbody> + <tr> + <th>Feature</th> + <th>Firefox (Gecko)</th> + <th>Chrome</th> + <th>Internet Explorer</th> + <th>Opera</th> + <th>Safari</th> + </tr> + <tr> + <td>Basic support</td> + <td>{{CompatVersionUnknown()}}</td> + <td>{{CompatVersionUnknown()}}</td> + <td>{{CompatVersionUnknown()}}</td> + <td>{{CompatVersionUnknown()}}</td> + <td>{{CompatVersionUnknown()}}</td> + </tr> + <tr> + <td>{{domxref("MouseEvent.movementX","movementX")}}<br> + {{domxref("MouseEvent.movementY","movementY")}}</td> + <td>{{CompatVersionUnknown()}} {{property_prefix("moz")}}</td> + <td>{{CompatVersionUnknown()}} {{property_prefix("webkit")}}</td> + <td>{{ CompatUnknown() }}</td> + <td>{{ CompatUnknown() }}</td> + <td>{{ CompatUnknown() }}</td> + </tr> + <tr> + <td>{{ domxref("MouseEvent.buttons", "buttons") }}</td> + <td>{{ CompatVersionUnknown() }}</td> + <td>{{ CompatNo() }}</td> + <td>{{ CompatUnknown() }}</td> + <td>{{ CompatUnknown() }}</td> + <td>{{ CompatUnknown() }}</td> + </tr> + <tr> + <td>{{ domxref("MouseEvent.which", "which") }}</td> + <td>1.0</td> + <td>1.0</td> + <td>9.0</td> + <td>5.0</td> + <td>1.0</td> + </tr> + <tr> + <td>{{domxref("MouseEvent.getModifierState()", "getModifierState()")}}</td> + <td>{{CompatGeckoDesktop(15)}}</td> + <td>{{CompatVersionUnknown()}}</td> + <td>{{CompatVersionUnknown()}}</td> + <td>{{CompatVersionUnknown()}}</td> + <td>{{CompatVersionUnknown()}}</td> + </tr> + <tr> + <td>{{domxref("MouseEvent.mozPressure", "mozPressure")}} and {{domxref("MouseEvent.mozInputSource", "mozInputSource")}} {{non-standard_inline}}</td> + <td>{{CompatGeckoDesktop(2)}}</td> + <td>{{CompatNo}}</td> + <td>{{CompatNo}}</td> + <td>{{CompatNo}}</td> + <td>{{CompatNo}}</td> + </tr> + <tr> + <td>{{domxref("MouseEvent.MouseEvent", "MouseEvent()")}}</td> + <td>{{CompatGeckoDesktop(11)}}</td> + <td>{{CompatVersionUnknown()}}</td> + <td>{{ CompatUnknown() }}</td> + <td>{{CompatVersionUnknown()}}</td> + <td>{{ CompatUnknown() }}</td> + </tr> + <tr> + <td>{{domxref("MouseEvent.region")}}</td> + <td>{{CompatGeckoDesktop(32)}}</td> + <td>{{ CompatUnknown() }}</td> + <td>{{ CompatUnknown() }}</td> + <td>{{ CompatUnknown() }}</td> + <td>{{ CompatUnknown() }}</td> + </tr> + </tbody> +</table> +</div> + +<div id="compat-mobile"> +<table class="compat-table"> + <tbody> + <tr> + <th>Feature</th> + <th>Firefox Mobile (Gecko)</th> + <th>Android</th> + <th>IE Mobile</th> + <th>Opera Mobile</th> + <th>Safari Mobile</th> + </tr> + <tr> + <td>Basic support</td> + <td>{{ CompatUnknown() }}</td> + <td>{{ CompatUnknown() }}</td> + <td>{{ CompatUnknown() }}</td> + <td>{{ CompatUnknown() }}</td> + <td>{{ CompatUnknown() }}</td> + </tr> + </tbody> +</table> +</div> + +<h2 id="See_also">See also</h2> + +<ul> + <li>Its direct parent, {{domxref("UIEvent")}}.</li> +</ul> diff --git a/files/es/web/api/mouseevent/initmouseevent/index.html b/files/es/web/api/mouseevent/initmouseevent/index.html new file mode 100644 index 0000000000..0e5a795b27 --- /dev/null +++ b/files/es/web/api/mouseevent/initmouseevent/index.html @@ -0,0 +1,60 @@ +--- +title: event.initMouseEvent +slug: Web/API/MouseEvent/initMouseEvent +tags: + - Referencia_DOM_de_Gecko +translation_of: Web/API/MouseEvent/initMouseEvent +--- +<p>{{ApiRef("DOM Events")}}{{deprecated_header}}</p> + +<div class="note"> +<p><strong>No utilize este método porque está obsoleto.</strong></p> + +<p>Usa constructores de eventos específicos, como {{domxref("MouseEvent.MouseEvent", "MouseEvent()")}}. La página <a href="/en-US/docs/Web/Guide/Events/Creating_and_triggering_events">Creando y disparando eventos</a> da más información sobre cómo usarlos.</p> +</div> + +<h3 id="Resumen" name="Resumen">Resumen</h3> + +<p>Asigna el valor inicial de un evento de ratón una vez creado (normalmente usando el método <a href="/es/docs/Web/API/Document/createEvent">document.createEvent</a>).</p> + +<h3 id="Sintaxis" name="Sintaxis">Sintaxis</h3> + +<pre class="eval"><em>event</em>.initMouseEvent(<em>type</em>,<em>canBubble</em>,<em>cancelable</em>,<em>view</em>,<em>detail</em>,<em>screenX</em>,<em>screenY</em>,<em>clientX</em>,<em>clientY</em>,<em>ctrlKey</em>,<em>altKey</em>,<em>shiftKey</em>,<em>metaKey</em>,<em>button</em>,<em>relatedTarget</em>); +</pre> + +<dl> + <dt><code>type</code></dt> + <dd>la cadena del <a href="es/DOM/event.type">type</a>. Los tipos posibles para un evento de ratón incluyen: <code>click</code>, <code>mousedown</code>, <code>mouseup</code>, <code>mouseover</code>, <code>mousemove</code>, <code>mouseout</code>.</dd> + <dt><code>canBubble</code></dt> + <dd>si el elemento puede ser recurrente. Pone el valor de <a href="es/DOM/event.bubbles">event.bubbles</a>.</dd> + <dt><code>cancelable</code></dt> + <dd>si la acción inicial del evento puede o no ser cancelada. Pone el valor de <a href="es/DOM/event.cancelable">event.cancelable</a>.</dd> + <dt><code>view</code></dt> + <dd>el valor AbstractView del evento. Aquí debes pasar el objeto <a href="es/DOM/window">window</a>. Pone el valor de <a href="es/DOM/event.view">event.view</a>.</dd> + <dt><code>detail</code></dt> + <dd>el contador de clic del evento. Pone el valor de <a href="es/DOM/event.detail">event.detail</a>.</dd> + <dt><code>screenX</code></dt> + <dd>la coordenada x en pantalla donde ha ocurrido el evento. Pone el valor de <a href="es/DOM/event.screenX">event.screenX</a>.</dd> + <dt><code>screenY</code></dt> + <dd>la coordenada y en pantalla donde ha ocurrido el evento. Pone el valor de <a href="es/DOM/event.screenY">event.screenY</a>.</dd> + <dt><code>clientX</code></dt> + <dd>la coordenada client x donde ha ocurrido el evento. Pone el valor de <a href="es/DOM/event.clientX">event.clientX</a>.</dd> + <dt><code>clientY</code></dt> + <dd>la coordenada client y donde ha ocurrido el evento. Pone el valor de <a href="es/DOM/event.clientY">event.clientY</a>.</dd> + <dt><code>ctrlKey</code></dt> + <dd>si se ha pulsado o no la tecla Control mientras ha ocurrido el evento. Pone el valor de <a href="es/DOM/event.ctrlKey">event.ctrlKey</a>.</dd> + <dt><code>altKey</code></dt> + <dd>si se ha pulsado o no la tecla Alt mientras ha ocurrido el evento. Pone el valor de <a href="es/DOM/event.altKey">event.altKey</a>.</dd> + <dt><code>shiftKey</code></dt> + <dd>si se ha pulsado o no la tecla Mayúsculas mientras ha ocurrido el evento. Pone el valor de <a href="es/DOM/event.shiftKey">event.shiftKey</a>.</dd> + <dt><code>metaKey</code></dt> + <dd>si se ha pulsado o no una meta tecla mientras ha ocurrido el evento. Pone el valor de <a href="es/DOM/event.metaKey">event.metaKey</a>.</dd> + <dt><code>button</code></dt> + <dd>el ratón del evento <a href="es/DOM/event.button">event.button</a>.</dd> + <dt><code>relatedTarget</code></dt> + <dd>el destino del evento <a href="es/DOM/event.relatedTarget">related EventTarget</a>. Sólo se usa con algún tipo de evento (ejemplo: <code>mouseover</code> y <code>mouseout</code>). En otros casos, devuelve <code>null</code>.</dd> +</dl> + +<h3 id="Especificaci.C3.B3n" name="Especificaci.C3.B3n">Especificación</h3> + +<p><a class="external" href="http://www.w3.org/TR/DOM-Level-2-Events/events.html#Events-Event-initMouseEvent">DOM Level 2 Events: initMouseEvent</a></p> diff --git a/files/es/web/api/mouseevent/shiftkey/index.html b/files/es/web/api/mouseevent/shiftkey/index.html new file mode 100644 index 0000000000..7f2fc25d61 --- /dev/null +++ b/files/es/web/api/mouseevent/shiftkey/index.html @@ -0,0 +1,126 @@ +--- +title: MouseEvent.shiftKey +slug: Web/API/MouseEvent/shiftKey +translation_of: Web/API/MouseEvent/shiftKey +--- +<p>{{APIRef("DOM Events")}}</p> + +<p>El evento de <strong><code>MouseEvent.shiftKey</code></strong> es una propiedad de solo lectura que indica si la tecla de <kbd>shift</kbd> se presionó (<code>true</code>) o no (<code>false</code>).</p> + +<h2 id="Sintaxis">Sintaxis</h2> + +<pre class="syntaxbox">var <em>shiftKeyPressed</em> = <em>instanceOfMouseEvent</em>.shiftKey +</pre> + +<h3 id="Valor_que_retorna">Valor que retorna</h3> + +<p>Un valor booleano</p> + +<h2 id="Example" name="Example">Ejemplo</h2> + +<pre class="brush: js"><html> +<head> +<title>Ejemplo de shiftKey</title> + +<script type="text/javascript"> + +function showChar(e){ + alert( + "Tecla presionada: " + String.fromCharCode(e.charCode) + "\n" + + "charCode: " + e.charCode + "\n" + + "SHIFT presionada: " + e.shiftKey + "\n" + + "ALT presionado: " + e.altKey + "\n" + ); +} + +</script> +</head> + +<body onkeypress="showChar(event);"> +<p>Presione cualquier tecla, con o sin la tecla SHIFT.<br /> +También puede utilizar SHIFT junto a la tecla ALT.</p> +</body> +</html> +</pre> + +<h2 id="Especificación">Especificación</h2> + +<table class="standard-table"> + <tbody> + <tr> + <th scope="col">Especificación</th> + <th scope="col">Estado</th> + <th scope="col">Comentario</th> + </tr> + <tr> + <td>{{SpecName('DOM3 Events','#widl-MouseEvent-shiftKey','MouseEvent.shiftKey')}}</td> + <td>{{Spec2('DOM3 Events')}}</td> + <td>Sin cambios desde {{SpecName('DOM2 Events')}}.</td> + </tr> + <tr> + <td>{{SpecName('DOM2 Events','#Events-MouseEvent','MouseEvent.shiftKey')}}</td> + <td>{{Spec2('DOM2 Events')}}</td> + <td>Primera definición.</td> + </tr> + </tbody> +</table> + +<h2 id="Browser_compatibility" name="Browser_compatibility">Compatibilidad con navegadores</h2> + +<p>{{ CompatibilityTable() }}</p> + +<div id="compat-desktop"> +<table class="compat-table"> + <tbody> + <tr> + <th>Característica</th> + <th>Edge</th> + <th>Firefox (Gecko)</th> + <th>Chrome</th> + <th>Internet Explorer</th> + <th>Opera</th> + <th>Safari</th> + </tr> + <tr> + <td>Soporte Básico</td> + <td>{{CompatVersionUnknown}}</td> + <td>{{CompatVersionUnknown()}}</td> + <td>{{CompatVersionUnknown()}}</td> + <td>{{CompatVersionUnknown()}}</td> + <td>{{CompatVersionUnknown()}}</td> + <td>{{CompatVersionUnknown()}}</td> + </tr> + </tbody> +</table> +</div> + +<div id="compat-mobile"> +<table class="compat-table"> + <tbody> + <tr> + <th>Característica</th> + <th>Edge</th> + <th>Firefox Mobile (Gecko)</th> + <th>Android</th> + <th>IE Mobile</th> + <th>Opera Mobile</th> + <th>Safari Mobile</th> + </tr> + <tr> + <td>Soporte Básico</td> + <td>{{CompatVersionUnknown}}</td> + <td>{{ CompatUnknown() }}</td> + <td>{{ CompatUnknown() }}</td> + <td>{{ CompatUnknown() }}</td> + <td>{{ CompatUnknown() }}</td> + <td>{{ CompatUnknown() }}</td> + </tr> + </tbody> +</table> +</div> + +<h2 id="See_also" name="See_also">Ver más</h2> + +<ul> + <li>{{ domxref("MouseEvent") }}</li> +</ul> |
