I need help pressing the Enter key twice with a different action occurring after each keypress in AngularJS, for example:
- Press Enter
 - One action happens
 - Press Enter again
 - A different action happens
 
I can get the first action working, just not the second. Here's my code:
  $scope.enterPressed = 0;
  $document.bind('keydown', function (evt) {
    if (evt.which === 13) {
      alert('Enter pressed');
      if ($scope.enterPressed === 0) {
        $scope.enterPressed++;
        document.getElementById("result").innerHTML = "Enter pressed once. $scope.enterPressed is " + $scope.enterPressed;
      } else if ($scope.enterPressed === 1) {
        e.preventDefault();
        document.getElementById("result").innerHTML = "Enter pressed twice. $scope.enterPressed i: " + $scope.enterPressed;
      }
    }
  });
How can I get the second action to occur?
                        
You are using
e.preventDefault();buteis not defined