Avoid leaking implementation details in Canvas API

This commit is contained in:
Héctor Ramón Jiménez 2019-06-25 21:36:24 +02:00
parent 8f66d96915
commit 1596cc5d9e
7 changed files with 56 additions and 986 deletions

View file

@ -220,5 +220,8 @@ pub fn keyboard_modifiers(event: &KeyboardEvent) -> ModifiersState {
}
pub fn codepoint(event: &KeyboardEvent) -> char {
// `event.key()` always returns a non-empty `String`. Therefore, this should
// never panic.
// https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key
event.key().chars().next().unwrap()
}