From 7f3322d48e1e5e8dda04f4924226ac0bd91f2776 Mon Sep 17 00:00:00 2001 From: Masahiro FUJIMOTO Date: Sat, 1 Jan 2022 01:29:44 +0900 Subject: 2021/11/05 時点の英語版に同期 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- files/ja/web/api/mouseevent/shiftkey/index.md | 103 +++++++++++--------------- 1 file changed, 43 insertions(+), 60 deletions(-) (limited to 'files/ja/web/api/mouseevent/shiftkey') diff --git a/files/ja/web/api/mouseevent/shiftkey/index.md b/files/ja/web/api/mouseevent/shiftkey/index.md index 8e97c700ed..ddc633ad16 100644 --- a/files/ja/web/api/mouseevent/shiftkey/index.md +++ b/files/ja/web/api/mouseevent/shiftkey/index.md @@ -1,76 +1,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")}}

+{{APIRef("DOM Events")}} -

MouseEvent.shiftKeyは読み取り専用のプロパティです。  shift キーが押された (true) か離されている (false) かを各イベント時に表します。

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

文法

+## 値 -
var shiftKeyPressed = instanceOfMouseEvent.shiftKey
-
+論理値で、 `true` はキーが押されていたことを示し、 `false` はキーが押されていなかったことを示します。 -

返り値

+## 例 -

A boolean

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

使用例

+### HTML -
<html>
-<head>
-<title>shiftKey example</title>
+```html
+

shiftKey プロパティを試験するためにどこかをクリックしてください。

+

+``` -<script type="text/javascript"> +### JavaScript -function showChar(e){ - alert( - "Key Pressed: " + String.fromCharCode(e.charCode) + "\n" - + "charCode: " + e.charCode + "\n" - + "SHIFT key pressed: " + e.shiftKey + "\n" - + "ALT key pressed: " + e.altKey + "\n" - ); +```js +let log = document.querySelector('#log'); +document.addEventListener('click', logKey); + +function logKey(e) { + log.textContent = `Shift キーの押下状態: ${e.shiftKey}`; } +``` + +### 結果 + +{{EmbedLiveSample("Example")}} + +## 仕様書 + +{{Specifications}} + +## ブラウザーの互換性 + +{{Compat}} + +## 関連情報 -</script> -</head> - -<body onkeypress="showChar(event);"> -<p>シフトキーを押しながらアルファベットキーを押してみてください。<br /> -同様に Altキーとも同時に使うことができます。</p> -</body> -</html> -
- -

仕様

- - - - - - - - - - - - - - - - - - - -
仕様ステータス注釈
{{SpecName('DOM3 Events','#widl-MouseEvent-shiftKey','MouseEvent.shiftKey')}}{{Spec2('DOM3 Events')}}次から変更なし{{SpecName('DOM2 Events')}}.
{{SpecName('DOM2 Events','#Events-MouseEvent','MouseEvent.shiftKey')}}{{Spec2('DOM2 Events')}}初期の定義
- -

ブラウザの互換性

- -

{{Compat("api.MouseEvent.shiftKey")}}

- -

参考

- - +- {{ domxref("MouseEvent") }} -- cgit v1.2.3-54-g00ecf