0

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

1
  • Check if the event target is the body Commented Jan 5, 2016 at 18:01

1 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

1 Comment

The code snippet looks good. I'm just wondering, how would you test this in Qunit for example? Also, where do you put the above snippet in your Ember App? Thank you for your help epascarello

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.