Reputation: 1
I have a radio input and written an ng-click function in it. For ADA when the user navigates through the radio button it gets selected on up and down arrow keypress and the ng-click function gets triggered.
But, in the event I am not getting any keyCode and event.which is always "1" and event.type is "click".
Is there any way I can distinguish between mouse click and keypress in the controller function.
.html file
<input tabindex="0"
type="radio"
name="radio-btn{{index_value}}"
id="amountValue-{{index_value}}"
ng-click="getSelectedValue($event, amount.selectedValue)"
value="Pay Amount"
ng-model="amount.selectedValue">
controller.js
scope.getSelectedValue= function (event, selectedValue) {
console.log("event", event);
};
I've tried adding a directive and bind "key-down keypress" event to it. Inside the directive, I am getting the correct key code but don't know how to pass the keycode to the controller function.
Upvotes: 0
Views: 248
Reputation: 23
check event.which value . it will give you the button code value (example ENTER button is 13) .
scope.getSelectedValue= function (event, selectedValue) {
var e = e || window.event;
var button = (typeof e.which != "undefined") ? e.which : e.button;
console.log("button value is ->"+button);
};
Upvotes: 0