1

I am trying to create a DIV that responds to keypress events, specifically the up arrow and down arrow. When the div is open, I want the window/document to respond to specific keypress events. I've seen JQuery solutions, but I'd rather not use JQuery. What's the best way to accomplish this?

Specifically, I will have different audio volume images and I want these images to change with each keypress.

2 Answers 2

1
    $scope.keypress = function($event) {
     $scope.Key = $event.keyCode
     };

You can write in the div with ng-keydown="keypress($event)" codepen URL for reference-http://codepen.io/nagasai/pen/beEQRE

    -

Sign up to request clarification or add additional context in comments.

2 Comments

added alert for up and down arrow
No that's not what I'm looking for. I don't want an input field involved. When a div is open, I want the window to respond to specific keypress events.
1

The solution I found was by using vanilla JavaScript:

window.addEventListener('keydown', function(e){
    // some code here
});

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.