MouseEvent.shiftKey

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.

El evento de MouseEvent.shiftKey es una propiedad de solo lectura que indica si la tecla de shift se presionó (true) o no (false).

Sintaxis

var shiftKeyPressed = instanceOfMouseEvent.shiftKey

Valor que retorna

Un valor booleano

Ejemplo

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>

Especificaciones

Specification
UI Events
# dom-mouseevent-shiftkey

Compatibilidad con navegadores

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
shiftKey

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support

Ver más