UNPKG

test-scribe

Version:

Your sidekick for analog machine development. Run machines interactively and generate automated test scripts based on the outcome.

29 lines (25 loc) 630 B
/** * Directive for using rainbow syntax highlighter with angular */ angular.module('homepage') .directive('pressEscToClose', ['negotiateKeyboardEvent', '$document', function (negotiateKeyboardEvent, $document) { return { restrict: 'A', scope: { isOpen: '=' }, link: function(scope) { /** * When a key is pressed, check for special keystrokes... */ $document.on('keydown', function(e) { return negotiateKeyboardEvent(e, { '<ESC>': function(e) { scope.isOpen = false; scope.$apply(); } }); }); } }; }]);