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