Ukit modal prevent close on escape button

Viewed 2720

I'm using Uikit with Angularjs and i need create possibly a directive that prevent the closing of the Modal when i press esc button. I tried with this way:

mainApp.directive('ngEsc', function () {
    return function (scope, element, attrs) {
        element.bind("keydown keypress keyup", function (event) {
            if(event.which === 27) {
                event.preventDefault();
            }
        });
    };
});

And then put the directive on the modal

Test modal

But it still closes. Is there any other way?

3 Answers
Related