From 112eb7bb8f673c6e9ecd955634e0c392c054a9c0 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sven=20Sch=C3=B6ling?= Date: Wed, 26 Oct 2016 15:38:21 +0200 Subject: [PATCH] accesskey normalization --- js/kivi.ActionBar.js | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/js/kivi.ActionBar.js b/js/kivi.ActionBar.js index 17fd7f7bb..e85fbe45f 100644 --- a/js/kivi.ActionBar.js +++ b/js/kivi.ActionBar.js @@ -40,9 +40,30 @@ namespace('kivi', function(k){ if (target === undefined) { target = 'document'; } + + var normalized = $.map(keystring.split('+'), function(val, i) { + switch (val) { + case 'ctrl': + case 'alt': return val; + case 'enter': return 13; + default: + if (val.length == 1) { + return val.charChodeAt(0) + } else if (typeof val === 'number') { + return val + } else if (val % 1 === 0) { + return val % 1; + } else { + console.log('can not normalize access key token: ' + val); + } + } + }).join('+'); + + console.log(normalized) + if (!(target in this.actions)) this.actions[target] = {}; - this.actions[target][keystring] = action; + this.actions[target][normalized] = action; }, bind_targets: function(){ -- 2.20.1