New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

angular-keydown

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

angular-keydown

Angular service for keydown detection

latest
Source
npmnpm
Version
0.1.1
Version published
Weekly downloads
6
-14.29%
Maintainers
1
Weekly downloads
 
Created
Source

angular-keydown

Angular service for keydown detection

npm version Build Status Code Climate Test Coverage

devDependency Status

Sometimes, it could be useful to detect a pressed key during a click or another event. Let's say you have a validation button. It would rock if it pops up a confirmation message when you click on it, but not if you hold the shift key, right ?

Angular-keydown makes it really easy!

Demos & usage

http://msieurtoph.github.io/angular-keydown

Installation

npm i angular-keydown --save

Usage

Please, visit http://msieurtoph.github.io/angular-keydown for live examples.

angular.module('', ['msieurtoph.ngKeydown'])

.directive('myTest', ['Keydown', function(Keydown){
    return {
        restrict: 'A',
        link: function(scope){
            scope.click = function(){
                if (Keydown.shift){
                    scope.message = 'Shift key has been pressed when clicking!';
                } else {
                    scope.message = 'Shift key nas not been pressed when clicking!';
                }
            };
        }
    }]);
});
<button my-test ng-click="click()">Hold shift key and click me</button>
<pre ng-bind="message"></pre>

The service lets you know whether the following keys are pressed :

  • shift, ctrl, alt
  • up, down, right, left arrows
  • pgUp, pgDown
  • space, escape, enter, tab

For other keys you can look to Keydown.others[_theKeyCode_] For instance, Keydown.others[65] will equal true if the a key is down.

Keydown.pressed gives you the list of pressed keys. For instance, if a, b and c keys are down, Keydown.pressed will equal [65, 66, 67]

Keywords

angular

FAQs

Package last updated on 03 Jan 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts