From 24d42c1401d11fdae94711681c80ad22a3fe6a91 Mon Sep 17 00:00:00 2001 From: Florent Becker Date: Thu, 8 Oct 2020 00:27:30 +0200 Subject: [PATCH] Ajout des orateurices au clavier --- Cargo.toml | 1 + index.html | 9 ++++++--- src/lib.rs | 7 +++++++ 3 files changed, 14 insertions(+), 3 deletions(-) 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");