patternfly-yew 0.7.4

PatternFly 5 components for Yew
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
use yew::prelude::*;

/// Create a new callback handling only the case when the user pressed the enter key.
#[hook]
pub fn use_on_enter<F, D>(d: D, f: F) -> Callback<KeyboardEvent>
where
    F: Fn(&D) + 'static,
    D: PartialEq + 'static,
{
    use_callback(d, move |evt: KeyboardEvent, d| {
        if evt.key_code() == 13 {
            f(d)
        }
    })
}