aboutsummaryrefslogtreecommitdiff
path: root/files/ja/web/api/mouseevent/shiftkey/index.md
blob: ddc633ad167ad13ae4129122253c289912c8a97e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
---
title: MouseEvent.shiftKey
slug: Web/API/MouseEvent/shiftKey
tags:
  - API
  - DOM
  - DOM イベント
  - MouseEvent
  - プロパティ
  - 読み取り専用
  - リファレンス
browser-compat: api.MouseEvent.shiftKey
translation_of: Web/API/MouseEvent/shiftKey
---
{{APIRef("DOM Events")}}

**`MouseEvent.shiftKey`** は読み取り専用のプロパティで、このマウスイベントが発行されたときに <kbd>shift</kbd> キーが押されていたかどうかを示す論理値です。

## 値

論理値で、 `true` はキーが押されていたことを示し、 `false` はキーが押されていなかったことを示します。

## 例

この例では、 {{Event("click")}} イベントを発生させた際に `ctrlKey` プロパティを記録します。

### HTML

```html
<p><code>shiftKey</code> プロパティを試験するためにどこかをクリックしてください。</p>
<p id="log"></p>
```

### JavaScript

```js
let log = document.querySelector('#log');
document.addEventListener('click', logKey);

function logKey(e) {
  log.textContent = `Shift キーの押下状態: ${e.shiftKey}`;
}
```

### 結果

{{EmbedLiveSample("Example")}}

## 仕様書

{{Specifications}}

## ブラウザーの互換性

{{Compat}}

## 関連情報

- {{ domxref("MouseEvent") }}