Mohamed Nagy
Mohamed Nagy

Reputation: 1058

Angular-strap close popover when clicking ESC from keyboard

I'm using Angular-strap, auto-close directive close the popover when clicking outside of it, what about ESC button ? how can i close the popover when ESC button clicked from keyboard ?

Upvotes: 1

Views: 502

Answers (1)

beaudetious
beaudetious

Reputation: 2416

Here's another SO question that's related to your question though it uses a jQuery approach which you may need to integrate into your app:

Close Bootstrap popover on esc keypress

Here's the demo: Plunker demo

Here's the jQuery approach:

$(document).keyup(function (event) {
    if (event.which === 27) {
        $('#example').popover('hide');
    }
});

Upvotes: 1

Related Questions