Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #2395 from arian/fix-2375-keyup-f-keys

Fixes #2375 - event.key is now correctly set for F keys on keyup
  • Loading branch information...
commit 906f2a15b240324f9928e2c6f65dbe3c9b9257c1 2 parents 302ba55 + 714379d
@cpojer cpojer authored
View
2  Source/Types/DOMEvent.js
@@ -36,7 +36,7 @@ var DOMEvent = this.DOMEvent = new Type('DOMEvent', function(event, win){
if (type.indexOf('key') == 0){
var code = this.code = (event.which || event.keyCode);
this.key = _keys[code]/*<1.3compat>*/ || Object.keyOf(Event.Keys, code)/*</1.3compat>*/;
- if (type == 'keydown'){
+ if (type == 'keydown' || type == 'keyup'){
if (code > 111 && code < 124) this.key = 'f' + (code - 111);
else if (code > 95 && code < 106) this.key = code - 96;
}
View
28 Specs/1.4client/Element/Element.Event.js
@@ -110,4 +110,32 @@ describe('Element.Event.change', function(){
});
+describe('Element.Event keyup with f<key>', function(){
+
+ it('should pass event.key == f2 when pressing f2 on keyup and keydown', function(){
+
+ var keydown = jasmine.createSpy('keydown');
+ var keyup = jasmine.createSpy('keyup');
+
+ var div = createElement('div')
+ .addEvent('keydown', function(event){
+ keydown(event.key);
+ })
+ .addEvent('keyup', function(event){
+ keyup(event.key);
+ })
+ .inject(document.body);
+
+ Syn.trigger('keydown', 'f2', div);
+ Syn.trigger('keyup', 'f2', div);
+
+ expect(keydown).toHaveBeenCalledWith('f2');
+ expect(keyup).toHaveBeenCalledWith('f2');
+
+ div.destroy();
+
+ });
+
+});
+
})();
Please sign in to comment.
Something went wrong with that request. Please try again.