File tree Expand file tree Collapse file tree 2 files changed +31
-4
lines changed
test/unit/specs/directives/public Expand file tree Collapse file tree 2 files changed +31
-4
lines changed Original file line number Diff line number Diff line change @@ -15,11 +15,17 @@ var keyCodes = {
1515
1616function keyFilter ( handler , keys ) {
1717 var codes = keys . map ( function ( key ) {
18- var code = keyCodes [ key ]
19- if ( ! code ) {
20- code = parseInt ( key , 10 )
18+ var charCode = key . charCodeAt ( 0 )
19+ if ( charCode > 47 && charCode < 58 ) {
20+ return parseInt ( key , 10 )
2121 }
22- return code
22+ if ( key . length === 1 ) {
23+ charCode = key . toUpperCase ( ) . charCodeAt ( 0 )
24+ if ( charCode > 64 && charCode < 91 ) {
25+ return charCode
26+ }
27+ }
28+ return keyCodes [ key ]
2329 } )
2430 return function keyHandler ( e ) {
2531 if ( codes . indexOf ( e . keyCode ) > - 1 ) {
Original file line number Diff line number Diff line change @@ -110,6 +110,27 @@ if (_.inBrowser) {
110110 } )
111111 } )
112112
113+ it ( 'with key modifier (letter)' , function ( done ) {
114+ new Vue ( {
115+ el : el ,
116+ template : '<a v-on:keyup.a="test">{{a}}</a>' ,
117+ data : { a : 1 } ,
118+ methods : {
119+ test : function ( ) {
120+ this . a ++
121+ }
122+ }
123+ } )
124+ var a = el . firstChild
125+ trigger ( a , 'keyup' , function ( e ) {
126+ e . keyCode = 65
127+ } )
128+ _ . nextTick ( function ( ) {
129+ expect ( a . textContent ) . toBe ( '2' )
130+ done ( )
131+ } )
132+ } )
133+
113134 it ( 'stop modifier' , function ( ) {
114135 var outer = jasmine . createSpy ( 'outer' )
115136 var inner = jasmine . createSpy ( 'inner' )
You can’t perform that action at this time.
0 commit comments