diff --git a/Cargo.toml b/Cargo.toml index ceeed7a..63eddac 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -34,6 +34,7 @@ features = [ 'HtmlCollection', 'HtmlInputElement', 'HtmlOListElement', + 'KeyboardEvent', 'Node', 'NodeList', 'Window', diff --git a/index.html b/index.html index ae06797..43635fe 100644 --- a/index.html +++ b/index.html @@ -3,7 +3,7 @@ Kikikoz @@ -26,7 +27,8 @@
-

Ajouter:

+

Ajouter: +

@@ -34,7 +36,8 @@
-

Ajouter:

+

Ajouter: +

diff --git a/src/lib.rs b/src/lib.rs index 0efa067..f4c7698 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -45,6 +45,13 @@ pub fn next() { } } +#[wasm_bindgen] +pub fn ajoute_kp(ev: web_sys::KeyboardEvent, id: &str) { + if ev.key_code() == 13 { + ajoute(id) + } +} + #[wasm_bindgen] pub fn ajoute(id: &str) { let window = web_sys::window().expect("no global `window` exists");