Reputation: 20760
Is there a way in EmberJs to disable the backspace
key, so it doesn't navigate back in the browser history?
Currently using EmberJs 2.0
I did find this possible answer:
https://stackoverflow.com/a/1235723/1913888
But one trick to this, is that a backspace
action should work for example in an input box, but not for navigating back in the window history.
Thank you
Upvotes: 0
Views: 123
Reputation: 207501
In my app, I just listen for the keydown and check to see if it is triggered on the body.
$(window).on("keydown", function(evt){
if (evt.keyCode===8 && evt.target.nodeName==="BODY") {
evt.preventDefault();
}
});
Other option is to check to make sure the target is not an input/content-editable.
Upvotes: 2