/
KeyboardEvent.cljs
248 lines (177 loc) · 7.54 KB
/
KeyboardEvent.cljs
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
(ns web.keyboard.KeyboardEvent
"KeyboardEvent objects describe a user interaction with the keyboard;
event describes a single interaction between the user and a key
combination of a key with modifier keys) on the keyboard."
(:refer-clojure :exclude [key repeat]))
(def constructor
"Constructor.
The KeyboardEvent() constructor creates a new `web.keyboard.KeyboardEvent`.
See also: `https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/KeyboardEvent`"
js/KeyboardEvent)
(defn get-modifier-state
"Method.
The KeyboardEvent.getModifierState() method returns the current
of the specified modifier key: true if the modifier is active
is the modifier key is pressed or locked), otherwise, false.
`var active = event.getModifierState(keyArg);`
See also: `https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/getModifierState`"
[this key-arg]
(-> this (.getModifierState key-arg)))
(defn init-keyboard-event
"Method.
The KeyboardEvent.initKeyboardEvent() method initializes the
of a keyboard event object. This method was introduced in draft
DOM Level 3 Events, but deprecated in newer draft. Gecko won't
this feature since implementing this method as experimental broke
web apps (see bug 999645). Web applications should use constructor
of this if it's available.
`kbdEvent.initKeyboardEvent(typeArg, canBubbleArg, cancelableArg,
viewArg, charArg, keyArg,
locationArg, modifiersListArg, repeat)`
See also: `https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/initKeyboardEvent`"
[this & args]
(apply (-> this .-initKeyboardEvent) (concat [this] args)))
(defn init-key-event
"Method.
The KeyboardEvent.initKeyEvent() method is used to initialize
value of an event created using `document.createEvent`(\\\"KeyboardEvent\\\").
initialized in this way must have been created with the `document.createEvent`(\\\"KeyboardEvent\\\")
initKeyEvent() must be called to set the event before it is dispatched.
`event.initKeyEvent (type, bubbles, cancelable, viewArg,
ctrlKeyArg, altKeyArg, shiftKeyArg, metaKeyArg,
keyCodeArg, charCodeArg)`
See also: `https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/initKeyEvent`"
[this & args]
(apply (-> this .-initKeyEvent) (concat [this] args)))
(defn alt-key
"Property.
The KeyboardEvent.altKey read-only property is a `js.Boolean`
indicates if the alt key (Option or ⌥ on OS X) was pressed (true)
not (false) when the event occured.
`var altKeyPressed = instanceOfKeyboardEvent.altKey`
See also: `https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/altKey`"
[this]
(-> this (.altKey)))
(defn char-code
"Property.
The charCode read-only property of the `web.keyboard.KeyboardEvent`
returns the Unicode value of a character key pressed during a
event.
`var code = event.charCode;`
See also: `https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/charCode`"
[this]
(-> this (.charCode)))
(defn set-char-code!
"Property.
The charCode read-only property of the `web.keyboard.KeyboardEvent`
returns the Unicode value of a character key pressed during a
event.
`var code = event.charCode;`
See also: `https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/charCode`"
[this val]
(aset this "charCode" val))
(defn code
"Property.
The KeyboardEvent.code property represents a physical key on
keyboard (as opposed to the character generated by pressing the
In other words, this property returns a value which isn't altered
keyboard layout or the state of the modifier keys.
See also: `https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/code`"
[this]
(-> this (.code)))
(defn ctrl-key
"Property.
The KeyboardEvent.ctrlKey read-only property returns a `js.Boolean`
indicates if the control key was pressed (true) or not (false)
the event occured.
`var ctrlKeyPressed = instanceOfKeyboardEvent.ctrlKey`
See also: `https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/ctrlKey`"
[this]
(-> this (.ctrlKey)))
(defn is-composing
"Property.
The KeyboardEvent.isComposing read-only property returns a `js.Boolean`
indicating if the event is fired after compositionstart and before
`var bool = event.isComposing;`
See also: `https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/isComposing`"
[this]
(-> this (.isComposing)))
(defn key
"Property.
The `web.keyboard.KeyboardEvent` interface's key read-only property
the value of the key pressed by the user, taking into consideration
state of modifier keys such as Shift as well as the keyboard
and layout.
See also: `https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key`"
[this]
(-> this (.key)))
(defn key-code
"Property.
The deprecated KeyboardEvent.keyCode read-only property represents
system and implementation dependent numerical code identifying
unmodified value of the pressed key.
See also: `https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/keyCode`"
[this]
(-> this (.keyCode)))
(defn key-identifier
"Property.
The deprecated KeyboardEvent.keyIdentifier read-only property
a \\\"key identifier\\\" string that can be used to determine what
was pressed. Its non-deprecated replacement is `KeyboardEvent.key`.
See also: `https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/keyIdentifier`"
[this]
(-> this (.keyIdentifier)))
(defn set-key-identifier!
"Property.
The deprecated KeyboardEvent.keyIdentifier read-only property
a \\\"key identifier\\\" string that can be used to determine what
was pressed. Its non-deprecated replacement is `KeyboardEvent.key`.
See also: `https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/keyIdentifier`"
[this val]
(aset this "keyIdentifier" val))
(defn location
"Property.
The KeyboardEvent.location read-only property returns an unsigned
representing the location of the key on the keyboard or other
device.
`var location = event.location;`
See also: `https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/location`"
[this]
(-> this (.location)))
(defn meta-key
"Property.
The KeyboardEvent.metaKey read-only property returning a `js.Boolean`
indicates if the Meta key was pressed (true) or not (false) when
event occurred. Some operating systems may intercept the key
it is never detected.
`var metaKeyPressed = instanceOfKeyboardEvent.metaKey`
See also: `https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/metaKey`"
[this]
(-> this (.metaKey)))
(defn repeat
"Property.
The repeat read-only property of the `web.keyboard.KeyboardEvent`
returns a `js.Boolean` that is true if the given key is being
down such that it is automatically repeating.
`var repeat = event.repeat;`
See also: `https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/repeat`"
[this]
(-> this (.repeat)))
(defn shift-key
"Property.
The KeyboardEvent.shiftKey read-only property is a `js.Boolean`
indicates if the shift key was pressed (true) or not (false)
the event occurred.
`var shiftKeyPressed = instanceOfKeyboardEvent.shiftKey`
See also: `https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/shiftKey`"
[this]
(-> this (.shiftKey)))
(defn which
"Property.
The which read-only property of the `web.keyboard.KeyboardEvent`
returns the numeric keyCode of the key pressed, or the character
(charCode) for an alphanumeric key pressed.
`var keyResult = event.which;`
See also: `https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/which`"
[this]
(-> this (.which)))