1

I've written directives in the past to handle different keys being pressed in an input form, but for the issue I'm having, I'm needing to be able make it so that when a user presses the tab key, it will handle it the same way as it would as if they had hit the enter key (no losing focus, submit form if needs be...).

Is it possible to intercept that event and tell the app it's an enter key instead, and then just do an event.preventDefault() or something?

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
m0ngr31
  • 791
  • 13
  • 29
  • 1
    Can you share the code that you're currently using? – Daniel Weiner Jan 15 '15 at 22:22
  • @DanielWeiner: I'm not currently using any code, just referencing that I've handled key presses in the past. I just don't know how to simulate a new keypress. – m0ngr31 Jan 15 '15 at 22:35
  • 1
    @m0ngr31 so this might be a dupe of http://stackoverflow.com/q/596481/3702797 – Kaiido Jan 15 '15 at 22:42
  • 1
    I wouldn't recommend changing the default behavior of tab because it's a usability issue. However, if you're set on doing that, you can use `event.preventDefault` and then follow the method used [here](http://stackoverflow.com/a/12187302/2498122) – Daniel Weiner Jan 15 '15 at 22:43
  • Does this answer your question? [Is it possible to simulate key press events programmatically?](https://stackoverflow.com/questions/596481/is-it-possible-to-simulate-key-press-events-programmatically) – Brian Tompsett - 汤莱恩 Dec 31 '19 at 17:26

0 Answers0