luid-keydown

An attribute directive to listen to keydown events

Features

An easy synthax to bind yourself to the keydown event.

Use this page to know the correspondance between key and code.

Supported arguments

Usage

<input ng-model="myValue" class="lui input" luid-keydown mappings="myMappings">
var enterPressed = function(){ ... };
		var escPressed = function(){ ... };
		$scope.myMappings = { 13: enterPressed, 27: escPressed, keyCode: fun };

Remarks

If in the function called you change a variable in the $scope, you have to call $scope.$apply(); yourself for this modification to take effect.

$scope.enterCnt = 0;
var enterPressed = function(){
$scope.enterCnt++;
$scope.$apply();
};
$scope.myMappings = { 13: enterPressed };

Will count the number of times keys enter, esc and the letter z are pressed, will also listen to arrow keys and append an array.