This repository was archived by the owner on Apr 12, 2024. It is now read-only.
File tree 2 files changed +26
-1
lines changed
2 files changed +26
-1
lines changed Original file line number Diff line number Diff line change 37
37
*/
38
38
var ngEventDirectives = { } ;
39
39
forEach (
40
- 'click dblclick mousedown mouseup mouseover mouseout mousemove mouseenter mouseleave keydown keyup' . split ( ' ' ) ,
40
+ 'click dblclick mousedown mouseup mouseover mouseout mousemove mouseenter mouseleave keydown keyup keypress ' . split ( ' ' ) ,
41
41
function ( name ) {
42
42
var directiveName = directiveNormalize ( 'ng-' + name ) ;
43
43
ngEventDirectives [ directiveName ] = [ '$parse' , function ( $parse ) {
@@ -196,6 +196,22 @@ forEach(
196
196
*/
197
197
198
198
199
+ /**
200
+ * @ngdoc directive
201
+ * @name ng.directive:ngKeypress
202
+ *
203
+ * @description
204
+ * Specify custom behavior on keypress event.
205
+ *
206
+ * @element ANY
207
+ * @param {expression } ngKeypress {@link guide/expression Expression } to evaluate upon
208
+ * keypress. (Event object is available as `$event` and can be interrogated for keyCode, altKey, etc.)
209
+ *
210
+ * @example
211
+ * See {@link ng.directive:ngClick ngClick}
212
+ */
213
+
214
+
199
215
/**
200
216
* @ngdoc directive
201
217
* @name ng.directive:ngSubmit
Original file line number Diff line number Diff line change @@ -25,5 +25,14 @@ describe('ngKeyup and ngKeydown directives', function() {
25
25
expect ( $rootScope . touched ) . toEqual ( true ) ;
26
26
} ) ) ;
27
27
28
+ it ( 'should get called on a keypress' , inject ( function ( $rootScope , $compile ) {
29
+ element = $compile ( '<input ng-keypress="touched = true">' ) ( $rootScope ) ;
30
+ $rootScope . $digest ( ) ;
31
+ expect ( $rootScope . touched ) . toBeFalsy ( ) ;
32
+
33
+ browserTrigger ( element , 'keypress' ) ;
34
+ expect ( $rootScope . touched ) . toEqual ( true ) ;
35
+ } ) ) ;
36
+
28
37
} ) ;
29
38
You can’t perform that action at this time.
0 commit comments