Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #538 from oruen/keypress_with_equal_keycode_and_ch…

…arcode

Keypress with equal keycode and charcode, refs #83
  • Loading branch information...
commit 8b45bcf188ac7056ed05f96fcf68df6de27bdea0 2 parents 328be9c + 778ece0
Colin Campbell authored
View
3  frameworks/core_foundation/system/event.js
@@ -920,7 +920,8 @@ SC.Event.prototype = {
var code=this.keyCode, ret=null, key=null, modifiers='', lowercase ;
// handle function keys.
- if (code) {
+ // WebKit browsers have equal values for keyCode and charCode on keypress event
+ if (code && code !== this.charCode) {
ret = SC.FUNCTION_KEYS[code] ;
if (!ret && (this.altKey || this.ctrlKey || this.metaKey)) {
ret = SC.PRINTABLE_KEYS[code];
View
22 frameworks/core_foundation/tests/system/event.js
@@ -0,0 +1,22 @@
+// ==========================================================================
+// Project: SproutCore - JavaScript Application Framework
+// Copyright: ©2006-2011 Strobe Inc. and contributors.
+// ©2008-2011 Apple Inc. All rights reserved.
+// License: Licensed under MIT license (see license.js)
+// ==========================================================================
+
+// // ========================================================================
+// SC.Event Tests
+// ========================================================================
+(function () {
+ module("SC.Event");
+
+ // WebKit browsers have equal values for keyCode and charCode on keypress event
+ test("commandCodes() : should handle equal keyCode and charCode on keypress", function () {
+ // 115 is alose keyCode for F4 button
+ var codes = new SC.Event({ type: 'keypress', keyCode: 115, charCode: 115 }).commandCodes();
+ equals(codes[0], null, 'command');
+ equals(codes[1], 's', 'char');
+ });
+})();
+
Please sign in to comment.
Something went wrong with that request. Please try again.