Skip to content

An angular directive adaptation of John Resig's jquery.hotkeys plugin

Notifications You must be signed in to change notification settings

alexxonline/angularkeycontrols

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 

Repository files navigation

Angular Key Controls

An angular directive adaptation of John Resig's jquery.hotkeys plugin.

#Requirements# It requires jquery.hotkeys present, you can download from: https://github.com/jeresig/jquery.hotkeys

#Usage# First you add the js to the page (make sure jquery.hotkeys and jquery are present). After that you must declare a dependency on keyControls

var app = angular.module("your-angular-app", [ "keyControls" ]);

Create in your controller a javscript object where the property name is the name of the key and the value is a reference to the function you want it to run when the key is pressed.

$scope.functionM = function() {
	console.debug("m");
};
$scope.functionC = function() {
	console.debug("c");
};
$scope.functionReturn = function() {
	console.debug("return");
};
$scope.functionEsc = function () {
	console.debug("esc");
};
$scope.KeyFunctions = 
		{
			"m": $scope.functionM
			"c": $scope.functionC
			"return": $scope.functionReturn
			"esc": $scope.functionEsc
		};

Then you add the attribute at the component you want the keys to react and the directive handles the rest.

<input type="text" key-controls="KeyFunctions">

About

An angular directive adaptation of John Resig's jquery.hotkeys plugin

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published