I have this shopping list app built in Angularjs which works just fine. I can add and delete items from it. But my issue is that I want to allow the app to add new items into the table using (event.which = 13) meaning using the "Enter" key from keyboard. Basically when user is on the input text field and after typing an item and pressing ENTER I want the new item to be added in my table. I think I'm close to accomplish this , but usually user will need to do this: type a text in input field and then press ENTER and then click anywhere outside the table in order to add the new item, but that wouldnt be the right way to add a new item. Please someone help on and let me know what I'm doing wrong. Thanks a lot in advance.
CodePen: http://codepen.io/HenryGranados/pen/BjWZKP
Here's my code:
$("#keypresser").keypress(function(e){
var codigo = e.which;
var item = document.getElementById("keypresser").value;
if(codigo == 13){
$scope.addNewItem(item);
console.log("Hello");
}
});