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[Constructor(DOMString typeArg, optional KeyboardEventInit keyboardEventInitDict)]
8interface KeyboardEvent : UIEvent
9{
10  readonly attribute unsigned long    charCode;
11  [NeedsCallerType]
12  readonly attribute unsigned long    keyCode;
13
14  [NeedsCallerType]
15  readonly attribute boolean          altKey;
16  [NeedsCallerType]
17  readonly attribute boolean          ctrlKey;
18  [NeedsCallerType]
19  readonly attribute boolean          shiftKey;
20  readonly attribute boolean          metaKey;
21
22  [NeedsCallerType]
23  boolean getModifierState(DOMString key);
24
25  const unsigned long DOM_KEY_LOCATION_STANDARD = 0x00;
26  const unsigned long DOM_KEY_LOCATION_LEFT     = 0x01;
27  const unsigned long DOM_KEY_LOCATION_RIGHT    = 0x02;
28  const unsigned long DOM_KEY_LOCATION_NUMPAD   = 0x03;
29
30  readonly attribute unsigned long location;
31  readonly attribute boolean       repeat;
32  readonly attribute boolean       isComposing;
33
34  readonly attribute DOMString key;
35  [NeedsCallerType]
36  readonly attribute DOMString code;
37
38  [Throws]
39  void initKeyboardEvent(DOMString typeArg,
40                         optional boolean bubblesArg = false,
41                         optional boolean cancelableArg = false,
42                         optional Window? viewArg = null,
43                         optional DOMString keyArg = "",
44                         optional unsigned long locationArg = 0,
45                         optional boolean ctrlKey = false,
46                         optional boolean altKey = false,
47                         optional boolean shiftKey = false,
48                         optional boolean metaKey = false);
49
50  // This returns the initialized dictionary for generating a
51  // same-type keyboard event
52  [Cached, ChromeOnly, Constant]
53  readonly attribute KeyboardEventInit initDict;
54};
55
56dictionary KeyboardEventInit : EventModifierInit
57{
58  DOMString      key           = "";
59  DOMString      code          = "";
60  unsigned long  location      = 0;
61  boolean        repeat        = false;
62  boolean        isComposing   = false;
63
64  // legacy attributes
65  unsigned long  charCode      = 0;
66  unsigned long  keyCode       = 0;
67  unsigned long  which         = 0;
68};
69