is there a way to trigger event when clicking on ENTER key in the input field? I found a directive that someone suggested to use, but I wonder if there is a simple way to do it.
I am using angular 1.3.
Check the event. And the following JavaScript code to detect whether the Enter key is pressed: const input = document. querySelector("input"); input. addEventListener("keyup", (event) => { if (event.
(keyup) is an Angular event binding to respond to any DOM event. It is a synchronous event that is triggered as the user is interacting with the text-based input controls. When a user presses and releases a key, the (keyup) event occurs.
$timeout(function() {
angular.element('#myselector').trigger('click');
}, 100);
If you want trigger on press on enter
key you need to write like that
<input ng-keyup="$event.keyCode == 13 ? myFunc() : null">
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With