Im trying to get my controller to watch for a combination of keys. Join the community of millions of developers who build compelling user interfaces with angular. Im using angularjs on a webapplication that i need to figure out how can i detect is keys like ctrl, shift or alt are pressed when i click some where. Were going to create a custom directive that will catch this enter keypress. I would generally recommend the directive handles the key method. How can i get angular to look out for these regardle. Contribute to iearthos angularjs atom development by creating an account on github.
Declarative templates with databinding, mvc, dependency injection and great testability story all implemented with pure clientside javascript. Type in this textbox when you and on the key up you will get the ascii value of the pressed key. In order to build the angular with the ng keyup option in place you can download the code from git and run rake package on the folder. In this example we have a form with some fields, on the click of the save button the entered data is displayed as saved data. Click on that you will see a dialog box like below to choose a minified version, select 1. To work with the angularjs we need to download and install angularjs library into the project.
Angular is a platform for building mobile and desktop web applications. Angularjs ngkeydown, ngkeyup, ngkeypress example dotnet. How to watch for a keypress combination in angularjs. This article explains the ng keyup and ng keydown directives of angularjs. In this section you will learn to download and install angularjs library. For this you can go to the angularjs official site or can download my. The angularjs ng keyup directive specifies the custom behavior of angularjs when you leave a key after pressing on the keyboard for a specific html element. As mentioned earlier download and install angularjs is a javascript. This example uses ngkeyup directive to change the background color when key up and down the button. Angularjs directive ngkeyup is used to specify a custom behaviour when keyup event is triggered. The ngkeyup directive tells angularjs what to do when the keyboard is used on the specific html element the ngkeyup directive from angularjs will not override the elements original onkeyup event, both will be executed the order of a key stroke is. Like mouse related directives, there are few key related directives also in angularjs and they are below.
235 1599 332 311 1260 52 1302 654 961 929 1288 211 522 1465 114 709 1182 1517 399 34 863 1473 1473 1353 375 1322 1116 205 336 79 630 537 668 1421