Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

Angular js Directive to Fire "click" event on pressing enter key on ANY element

angular
    .module('app.directives')
    .directive('enterKeyInput', enterKeyInput);

enterKeyInput.$inject = [];

/* @ngInject */
function enterKeyInput() {

    return {
        restrict: 'AC',
        link: function (scope, element, attrs) {
            element.bind('keyup', function (e)  {
                if ([13].indexOf(e.which) !== -1)  {
                    e.preventDefault();
                    e.stopPropagation();
                    element.click();
                }
            });
        }
    };
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: angularjs How to sort a specific value in a map 
Javascript :: Angularjs - Deep Orderby - How to handle multiple layers of sorting 
Javascript :: AngularJS disable default form submit hook 
Javascript :: Calling $http.post in batches and chaining promises 
Javascript :: AngularJS Form validation transition to valid when some elements are not even touched yet 
Javascript :: Relaxed "angularjs" style expression parsing missing in vue 
Javascript :: How to pass React Native Component as a JSON object 
Javascript :: Delete a field from Firebase Firestore where the field/key has a period/punctuation (".") - modular v9 JavaScript SDK 
Javascript :: react-native installation error with npx react-native 
Javascript :: How to check the increase/decrease of letter input in pasting clipboard in jQuery 
Javascript :: reverse array without using another array 
Javascript :: PAN SNAP 
Javascript :: How to access POST form fields in Express 
Javascript :: jquery call service 
Javascript :: How To Use Matches() In JavaScript 
Javascript :: echarts js 
Javascript :: how can do i open the select tag using keyboard event using javascript site:stackoverflow.com 
Javascript :: phaser rotate matrix 180 
Javascript :: vimscript replace function 
Javascript :: node-schedule cancel job 
Javascript :: SordMap elo 
Javascript :: communicate between content script and bg 
Javascript :: node-red function string to int 
Javascript :: How to Solve the Parking Lot Challenge in JavaScript 
Javascript :: How to sum to small numbers 
Javascript :: javascript protect object with proxy 
Javascript :: verify if user input is equal to javascript 
Javascript :: How many options are there to climb a ladder with N 
Javascript :: use strict print this 
Javascript :: react tutorial app 
ADD CONTENT
Topic
Content
Source link
Name
7+6 =