Search code examples
javascripthtmlangularjskeypresskeyup

Using ng-keyup on non-input html tags


I have to use ng-keyup on some arrow keys. i am only able to use it on textarea and input type="text" tags.

I want to be able to use it on a div or body tag rather than the input tags so the user can just press arrow key when page loads to see the change. How do I do this?

Using AngularJS ngKeyup on a div rather than an input

I already tried using tabindex as is suggested by this answer but it didn't work.


Solution

  • It worked by shifting both the controller and ng-keyup to the body tag.