How to cancel backspace key from navigating back…

Don’t ask me who had the insane idea that one can navigate back when pressing the back space.

In GWT we did something like that to cancel the backspace back navigation:

3 thoughts on “How to cancel backspace key from navigating back…”

  1. Cool, this improves usablilty.

    But, if the focus is set to something else than the body, it will not work. So, I think, it will be better to define, where the backspace is allowed and where not.

    if (as.getTagName().toLowerCase().equals(“input”) ||
    as.getTagName().toLowerCase().equals(“textarea”)) {
    // Backspace allowed
    ;
    } else {
    event.getNativeEvent().stopPropagation();
    event.getNativeEvent().preventDefault();
    }

    What do you think?

  2. Thanks for this nice part of code :)

    I changed a little bit and it works for me very nice. Here is my changes:

    Element as = Element.as(event.getNativeEvent().getEventTarget());

    boolean readOnly = as.getPropertyBoolean(“readOnly”);
    boolean contentEditable = as.getPropertyBoolean(“isContentEditable”);
    if (readOnly || !contentEditable) {
    event.getNativeEvent().stopPropagation();
    event.getNativeEvent().preventDefault();
    }

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">