KeyboardEvent.webidl (2730B)
1 /* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 2 /* This Source Code Form is subject to the terms of the Mozilla Public 3 * License, v. 2.0. If a copy of the MPL was not distributed with this file, 4 * You can obtain one at http://mozilla.org/MPL/2.0/. 5 */ 6 7 [Exposed=Window] 8 interface KeyboardEvent : UIEvent 9 { 10 [BinaryName="constructorJS"] 11 constructor(DOMString typeArg, 12 optional KeyboardEventInit keyboardEventInitDict= {}); 13 14 [NeedsCallerType] 15 readonly attribute unsigned long charCode; 16 [NeedsCallerType] 17 readonly attribute unsigned long keyCode; 18 19 [NeedsCallerType] 20 readonly attribute boolean altKey; 21 [NeedsCallerType] 22 readonly attribute boolean ctrlKey; 23 [NeedsCallerType] 24 readonly attribute boolean shiftKey; 25 readonly attribute boolean metaKey; 26 27 [NeedsCallerType] 28 boolean getModifierState(DOMString key); 29 30 const unsigned long DOM_KEY_LOCATION_STANDARD = 0x00; 31 const unsigned long DOM_KEY_LOCATION_LEFT = 0x01; 32 const unsigned long DOM_KEY_LOCATION_RIGHT = 0x02; 33 const unsigned long DOM_KEY_LOCATION_NUMPAD = 0x03; 34 35 readonly attribute unsigned long location; 36 readonly attribute boolean repeat; 37 readonly attribute boolean isComposing; 38 39 readonly attribute DOMString key; 40 [NeedsCallerType] 41 readonly attribute DOMString code; 42 43 [BinaryName="initKeyboardEventJS"] 44 undefined initKeyboardEvent(DOMString typeArg, 45 optional boolean bubblesArg = false, 46 optional boolean cancelableArg = false, 47 optional Window? viewArg = null, 48 optional DOMString keyArg = "", 49 optional unsigned long locationArg = 0, 50 optional boolean ctrlKey = false, 51 optional boolean altKey = false, 52 optional boolean shiftKey = false, 53 optional boolean metaKey = false); 54 55 // This returns the initialized dictionary for generating a 56 // same-type keyboard event 57 [Cached, ChromeOnly, Constant] 58 readonly attribute KeyboardEventInit initDict; 59 }; 60 61 dictionary KeyboardEventInit : EventModifierInit 62 { 63 [BinaryType="nsAutoString"] 64 DOMString key = ""; 65 [BinaryType="nsAutoString"] 66 DOMString code = ""; 67 unsigned long location = 0; 68 boolean repeat = false; 69 boolean isComposing = false; 70 71 // legacy attributes 72 unsigned long charCode = 0; 73 unsigned long keyCode = 0; 74 unsigned long which = 0; 75 }; 76 77 // Mozilla extensions 78 KeyboardEvent includes KeyEventMixin;