Dart How to prevent chrome back to previous page when user press DELETE or BACKSPACE -
how can prevent browser previous page when user press backspace or delete in dart?
i have listening key events this:
// keyboard event streamsubkey = window.onkeyup.listen((keyboardevent e) { switch (e.keycode) { case keycode.backspace: case keycode.delete: // , stop browser previous. break; } });
case keycode.backspace:
should enough, delete
doesn't navigate anywhere.
just add e.preventdefault();
.
you want skip e.preventdefault();
when current element input element or textarea.
if(!(e.target inputelement || e.target textarea)) { e.preventdefault(); }
not tested
Comments
Post a Comment