Created
June 23, 2015 13:17
-
-
Save snapwich/4b08dd09521005a515d2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// keyboard and accessibility directive | |
.directive("ngClick", function() { | |
var KEY_ENTER = 13, | |
KEY_SPACE = 32; | |
return { | |
restrict: "A", | |
link: function(scope, elem, attrs) { | |
elem.css({ | |
cursor: "pointer" | |
}); | |
elem.on("keyup", function(e) { | |
switch(e.which) { | |
case KEY_ENTER: | |
case KEY_SPACE: | |
scope.$apply(function() { | |
scope.$eval(attrs.ngClick); | |
}); | |
break; | |
} | |
}) | |
} | |
}; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment