Skip to main content

web_sys/features/
gen_KeyboardEvent.rs

1#![allow(unused_imports)]
2#![allow(clippy::all)]
3use super::*;
4use wasm_bindgen::prelude::*;
5#[wasm_bindgen]
6extern "C" {
7    #[wasm_bindgen(
8        extends = "UiEvent",
9        extends = "Event",
10        extends = "::js_sys::Object",
11        js_name = "KeyboardEvent",
12        typescript_type = "KeyboardEvent"
13    )]
14    #[derive(Debug, Clone, PartialEq, Eq)]
15    #[doc = "The `KeyboardEvent` class."]
16    #[doc = ""]
17    #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent)"]
18    #[doc = ""]
19    #[doc = "*This API requires the following crate features to be activated: `KeyboardEvent`*"]
20    pub type KeyboardEvent;
21    #[wasm_bindgen(method, getter, js_class = "KeyboardEvent", js_name = "charCode")]
22    #[doc = "Getter for the `charCode` field of this object."]
23    #[doc = ""]
24    #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/charCode)"]
25    #[doc = ""]
26    #[doc = "*This API requires the following crate features to be activated: `KeyboardEvent`*"]
27    pub fn char_code(this: &KeyboardEvent) -> u32;
28    #[wasm_bindgen(method, getter, js_class = "KeyboardEvent", js_name = "keyCode")]
29    #[doc = "Getter for the `keyCode` field of this object."]
30    #[doc = ""]
31    #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/keyCode)"]
32    #[doc = ""]
33    #[doc = "*This API requires the following crate features to be activated: `KeyboardEvent`*"]
34    pub fn key_code(this: &KeyboardEvent) -> u32;
35    #[wasm_bindgen(method, getter, js_class = "KeyboardEvent", js_name = "altKey")]
36    #[doc = "Getter for the `altKey` field of this object."]
37    #[doc = ""]
38    #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/altKey)"]
39    #[doc = ""]
40    #[doc = "*This API requires the following crate features to be activated: `KeyboardEvent`*"]
41    pub fn alt_key(this: &KeyboardEvent) -> bool;
42    #[wasm_bindgen(method, getter, js_class = "KeyboardEvent", js_name = "ctrlKey")]
43    #[doc = "Getter for the `ctrlKey` field of this object."]
44    #[doc = ""]
45    #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/ctrlKey)"]
46    #[doc = ""]
47    #[doc = "*This API requires the following crate features to be activated: `KeyboardEvent`*"]
48    pub fn ctrl_key(this: &KeyboardEvent) -> bool;
49    #[wasm_bindgen(method, getter, js_class = "KeyboardEvent", js_name = "shiftKey")]
50    #[doc = "Getter for the `shiftKey` field of this object."]
51    #[doc = ""]
52    #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/shiftKey)"]
53    #[doc = ""]
54    #[doc = "*This API requires the following crate features to be activated: `KeyboardEvent`*"]
55    pub fn shift_key(this: &KeyboardEvent) -> bool;
56    #[wasm_bindgen(method, getter, js_class = "KeyboardEvent", js_name = "metaKey")]
57    #[doc = "Getter for the `metaKey` field of this object."]
58    #[doc = ""]
59    #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/metaKey)"]
60    #[doc = ""]
61    #[doc = "*This API requires the following crate features to be activated: `KeyboardEvent`*"]
62    pub fn meta_key(this: &KeyboardEvent) -> bool;
63    #[wasm_bindgen(method, getter, js_class = "KeyboardEvent", js_name = "location")]
64    #[doc = "Getter for the `location` field of this object."]
65    #[doc = ""]
66    #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/location)"]
67    #[doc = ""]
68    #[doc = "*This API requires the following crate features to be activated: `KeyboardEvent`*"]
69    pub fn location(this: &KeyboardEvent) -> u32;
70    #[wasm_bindgen(method, getter, js_class = "KeyboardEvent", js_name = "repeat")]
71    #[doc = "Getter for the `repeat` field of this object."]
72    #[doc = ""]
73    #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/repeat)"]
74    #[doc = ""]
75    #[doc = "*This API requires the following crate features to be activated: `KeyboardEvent`*"]
76    pub fn repeat(this: &KeyboardEvent) -> bool;
77    #[wasm_bindgen(method, getter, js_class = "KeyboardEvent", js_name = "isComposing")]
78    #[doc = "Getter for the `isComposing` field of this object."]
79    #[doc = ""]
80    #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/isComposing)"]
81    #[doc = ""]
82    #[doc = "*This API requires the following crate features to be activated: `KeyboardEvent`*"]
83    pub fn is_composing(this: &KeyboardEvent) -> bool;
84    #[wasm_bindgen(method, getter, js_class = "KeyboardEvent", js_name = "key")]
85    #[doc = "Getter for the `key` field of this object."]
86    #[doc = ""]
87    #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key)"]
88    #[doc = ""]
89    #[doc = "*This API requires the following crate features to be activated: `KeyboardEvent`*"]
90    pub fn key(this: &KeyboardEvent) -> ::alloc::string::String;
91    #[wasm_bindgen(method, getter, js_class = "KeyboardEvent", js_name = "code")]
92    #[doc = "Getter for the `code` field of this object."]
93    #[doc = ""]
94    #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/code)"]
95    #[doc = ""]
96    #[doc = "*This API requires the following crate features to be activated: `KeyboardEvent`*"]
97    pub fn code(this: &KeyboardEvent) -> ::alloc::string::String;
98    #[wasm_bindgen(catch, constructor, js_class = "KeyboardEvent")]
99    #[doc = "The `new KeyboardEvent(..)` constructor, creating a new instance of `KeyboardEvent`."]
100    #[doc = ""]
101    #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/KeyboardEvent)"]
102    #[doc = ""]
103    #[doc = "*This API requires the following crate features to be activated: `KeyboardEvent`*"]
104    pub fn new(type_arg: &str) -> Result<KeyboardEvent, JsValue>;
105    #[cfg(feature = "KeyboardEventInit")]
106    #[wasm_bindgen(catch, constructor, js_class = "KeyboardEvent")]
107    #[doc = "The `new KeyboardEvent(..)` constructor, creating a new instance of `KeyboardEvent`."]
108    #[doc = ""]
109    #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/KeyboardEvent)"]
110    #[doc = ""]
111    #[doc = "*This API requires the following crate features to be activated: `KeyboardEvent`, `KeyboardEventInit`*"]
112    pub fn new_with_keyboard_event_init_dict(
113        type_arg: &str,
114        keyboard_event_init_dict: &KeyboardEventInit,
115    ) -> Result<KeyboardEvent, JsValue>;
116    #[wasm_bindgen(method, js_class = "KeyboardEvent", js_name = "getModifierState")]
117    #[doc = "The `getModifierState()` method."]
118    #[doc = ""]
119    #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/getModifierState)"]
120    #[doc = ""]
121    #[doc = "*This API requires the following crate features to be activated: `KeyboardEvent`*"]
122    pub fn get_modifier_state(this: &KeyboardEvent, key: &str) -> bool;
123    #[wasm_bindgen(
124        catch,
125        method,
126        js_class = "KeyboardEvent",
127        js_name = "initKeyboardEvent"
128    )]
129    #[doc = "The `initKeyboardEvent()` method."]
130    #[doc = ""]
131    #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/initKeyboardEvent)"]
132    #[doc = ""]
133    #[doc = "*This API requires the following crate features to be activated: `KeyboardEvent`*"]
134    pub fn init_keyboard_event(this: &KeyboardEvent, type_arg: &str) -> Result<(), JsValue>;
135    #[wasm_bindgen(
136        catch,
137        method,
138        js_class = "KeyboardEvent",
139        js_name = "initKeyboardEvent"
140    )]
141    #[doc = "The `initKeyboardEvent()` method."]
142    #[doc = ""]
143    #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/initKeyboardEvent)"]
144    #[doc = ""]
145    #[doc = "*This API requires the following crate features to be activated: `KeyboardEvent`*"]
146    pub fn init_keyboard_event_with_bubbles_arg(
147        this: &KeyboardEvent,
148        type_arg: &str,
149        bubbles_arg: bool,
150    ) -> Result<(), JsValue>;
151    #[wasm_bindgen(
152        catch,
153        method,
154        js_class = "KeyboardEvent",
155        js_name = "initKeyboardEvent"
156    )]
157    #[doc = "The `initKeyboardEvent()` method."]
158    #[doc = ""]
159    #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/initKeyboardEvent)"]
160    #[doc = ""]
161    #[doc = "*This API requires the following crate features to be activated: `KeyboardEvent`*"]
162    pub fn init_keyboard_event_with_bubbles_arg_and_cancelable_arg(
163        this: &KeyboardEvent,
164        type_arg: &str,
165        bubbles_arg: bool,
166        cancelable_arg: bool,
167    ) -> Result<(), JsValue>;
168    #[cfg(feature = "Window")]
169    #[wasm_bindgen(
170        catch,
171        method,
172        js_class = "KeyboardEvent",
173        js_name = "initKeyboardEvent"
174    )]
175    #[doc = "The `initKeyboardEvent()` method."]
176    #[doc = ""]
177    #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/initKeyboardEvent)"]
178    #[doc = ""]
179    #[doc = "*This API requires the following crate features to be activated: `KeyboardEvent`, `Window`*"]
180    pub fn init_keyboard_event_with_bubbles_arg_and_cancelable_arg_and_view_arg(
181        this: &KeyboardEvent,
182        type_arg: &str,
183        bubbles_arg: bool,
184        cancelable_arg: bool,
185        view_arg: Option<&Window>,
186    ) -> Result<(), JsValue>;
187    #[cfg(feature = "Window")]
188    #[wasm_bindgen(
189        catch,
190        method,
191        js_class = "KeyboardEvent",
192        js_name = "initKeyboardEvent"
193    )]
194    #[doc = "The `initKeyboardEvent()` method."]
195    #[doc = ""]
196    #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/initKeyboardEvent)"]
197    #[doc = ""]
198    #[doc = "*This API requires the following crate features to be activated: `KeyboardEvent`, `Window`*"]
199    pub fn init_keyboard_event_with_bubbles_arg_and_cancelable_arg_and_view_arg_and_key_arg(
200        this: &KeyboardEvent,
201        type_arg: &str,
202        bubbles_arg: bool,
203        cancelable_arg: bool,
204        view_arg: Option<&Window>,
205        key_arg: &str,
206    ) -> Result<(), JsValue>;
207    #[cfg(feature = "Window")]
208    #[wasm_bindgen(
209        catch,
210        method,
211        js_class = "KeyboardEvent",
212        js_name = "initKeyboardEvent"
213    )]
214    #[doc = "The `initKeyboardEvent()` method."]
215    #[doc = ""]
216    #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/initKeyboardEvent)"]
217    #[doc = ""]
218    #[doc = "*This API requires the following crate features to be activated: `KeyboardEvent`, `Window`*"]
219    pub fn init_keyboard_event_with_bubbles_arg_and_cancelable_arg_and_view_arg_and_key_arg_and_location_arg(
220        this: &KeyboardEvent,
221        type_arg: &str,
222        bubbles_arg: bool,
223        cancelable_arg: bool,
224        view_arg: Option<&Window>,
225        key_arg: &str,
226        location_arg: u32,
227    ) -> Result<(), JsValue>;
228    #[cfg(feature = "Window")]
229    #[wasm_bindgen(
230        catch,
231        method,
232        js_class = "KeyboardEvent",
233        js_name = "initKeyboardEvent"
234    )]
235    #[doc = "The `initKeyboardEvent()` method."]
236    #[doc = ""]
237    #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/initKeyboardEvent)"]
238    #[doc = ""]
239    #[doc = "*This API requires the following crate features to be activated: `KeyboardEvent`, `Window`*"]
240    pub fn init_keyboard_event_with_bubbles_arg_and_cancelable_arg_and_view_arg_and_key_arg_and_location_arg_and_ctrl_key(
241        this: &KeyboardEvent,
242        type_arg: &str,
243        bubbles_arg: bool,
244        cancelable_arg: bool,
245        view_arg: Option<&Window>,
246        key_arg: &str,
247        location_arg: u32,
248        ctrl_key: bool,
249    ) -> Result<(), JsValue>;
250    #[cfg(feature = "Window")]
251    #[wasm_bindgen(
252        catch,
253        method,
254        js_class = "KeyboardEvent",
255        js_name = "initKeyboardEvent"
256    )]
257    #[doc = "The `initKeyboardEvent()` method."]
258    #[doc = ""]
259    #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/initKeyboardEvent)"]
260    #[doc = ""]
261    #[doc = "*This API requires the following crate features to be activated: `KeyboardEvent`, `Window`*"]
262    pub fn init_keyboard_event_with_bubbles_arg_and_cancelable_arg_and_view_arg_and_key_arg_and_location_arg_and_ctrl_key_and_alt_key(
263        this: &KeyboardEvent,
264        type_arg: &str,
265        bubbles_arg: bool,
266        cancelable_arg: bool,
267        view_arg: Option<&Window>,
268        key_arg: &str,
269        location_arg: u32,
270        ctrl_key: bool,
271        alt_key: bool,
272    ) -> Result<(), JsValue>;
273    #[cfg(feature = "Window")]
274    #[wasm_bindgen(
275        catch,
276        method,
277        js_class = "KeyboardEvent",
278        js_name = "initKeyboardEvent"
279    )]
280    #[doc = "The `initKeyboardEvent()` method."]
281    #[doc = ""]
282    #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/initKeyboardEvent)"]
283    #[doc = ""]
284    #[doc = "*This API requires the following crate features to be activated: `KeyboardEvent`, `Window`*"]
285    pub fn init_keyboard_event_with_bubbles_arg_and_cancelable_arg_and_view_arg_and_key_arg_and_location_arg_and_ctrl_key_and_alt_key_and_shift_key(
286        this: &KeyboardEvent,
287        type_arg: &str,
288        bubbles_arg: bool,
289        cancelable_arg: bool,
290        view_arg: Option<&Window>,
291        key_arg: &str,
292        location_arg: u32,
293        ctrl_key: bool,
294        alt_key: bool,
295        shift_key: bool,
296    ) -> Result<(), JsValue>;
297    #[cfg(feature = "Window")]
298    #[wasm_bindgen(
299        catch,
300        method,
301        js_class = "KeyboardEvent",
302        js_name = "initKeyboardEvent"
303    )]
304    #[doc = "The `initKeyboardEvent()` method."]
305    #[doc = ""]
306    #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/initKeyboardEvent)"]
307    #[doc = ""]
308    #[doc = "*This API requires the following crate features to be activated: `KeyboardEvent`, `Window`*"]
309    pub fn init_keyboard_event_with_bubbles_arg_and_cancelable_arg_and_view_arg_and_key_arg_and_location_arg_and_ctrl_key_and_alt_key_and_shift_key_and_meta_key(
310        this: &KeyboardEvent,
311        type_arg: &str,
312        bubbles_arg: bool,
313        cancelable_arg: bool,
314        view_arg: Option<&Window>,
315        key_arg: &str,
316        location_arg: u32,
317        ctrl_key: bool,
318        alt_key: bool,
319        shift_key: bool,
320        meta_key: bool,
321    ) -> Result<(), JsValue>;
322}
323impl KeyboardEvent {
324    #[doc = "The `KeyboardEvent.DOM_KEY_LOCATION_STANDARD` const."]
325    #[doc = ""]
326    #[doc = "*This API requires the following crate features to be activated: `KeyboardEvent`*"]
327    pub const DOM_KEY_LOCATION_STANDARD: u32 = 0u64 as u32;
328    #[doc = "The `KeyboardEvent.DOM_KEY_LOCATION_LEFT` const."]
329    #[doc = ""]
330    #[doc = "*This API requires the following crate features to be activated: `KeyboardEvent`*"]
331    pub const DOM_KEY_LOCATION_LEFT: u32 = 1u64 as u32;
332    #[doc = "The `KeyboardEvent.DOM_KEY_LOCATION_RIGHT` const."]
333    #[doc = ""]
334    #[doc = "*This API requires the following crate features to be activated: `KeyboardEvent`*"]
335    pub const DOM_KEY_LOCATION_RIGHT: u32 = 2u64 as u32;
336    #[doc = "The `KeyboardEvent.DOM_KEY_LOCATION_NUMPAD` const."]
337    #[doc = ""]
338    #[doc = "*This API requires the following crate features to be activated: `KeyboardEvent`*"]
339    pub const DOM_KEY_LOCATION_NUMPAD: u32 = 3u64 as u32;
340}