Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 6911b4b69c
Fetching contributors…

Cannot retrieve contributors at this time

29 lines (23 sloc) 0.648 kb
///<reference path="../def/angular.d.ts"/>
///<reference path="../def/jquery.d.ts"/>
console.log("KEYPRESS")
angular.module('directives')
.directive('keypress', function($parse) {
return function(scope:ng.IScope, element:JQuery, attrs) {
// element is a jquery element
// focus the div
element.attr('tabindex', 0)
var onPress = $parse(attrs.keypress)
var isPressed = false
element.keydown(function(e) {
if (isPressed) return
isPressed = true
scope.$apply(function() {
onPress(scope, {e:e})
})
});
element.keyup(function(e) {
isPressed = false
})
}
})
Jump to Line
Something went wrong with that request. Please try again.