summaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authorrsadam@chromium.org <rsadam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-09-24 21:34:39 +0000
committerrsadam@chromium.org <rsadam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-09-24 21:34:39 +0000
commit9984445bf0ab9516d862ca3318a4c1af9d894927 (patch)
tree6565396dbf652ea8ebc123957783ce9489b21c0a /ui
parentcf977b76c00a02922a6b888d363688e89dded110 (diff)
downloadchromium_src-9984445bf0ab9516d862ca3318a4c1af9d894927.zip
chromium_src-9984445bf0ab9516d862ca3318a4c1af9d894927.tar.gz
chromium_src-9984445bf0ab9516d862ca3318a4c1af9d894927.tar.bz2
Implemented chording. Pressing down the shift key while typing other characters will now transition to capslock until the shift key is released.
BUG=252707 Review URL: https://chromiumcodereview.appspot.com/23496075 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@225065 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui')
-rw-r--r--ui/keyboard/resources/elements/kb-keyboard.html16
-rw-r--r--ui/keyboard/resources/elements/kb-shift-key.html21
2 files changed, 25 insertions, 12 deletions
diff --git a/ui/keyboard/resources/elements/kb-keyboard.html b/ui/keyboard/resources/elements/kb-keyboard.html
index ea09e37..e515b65 100644
--- a/ui/keyboard/resources/elements/kb-keyboard.html
+++ b/ui/keyboard/resources/elements/kb-keyboard.html
@@ -427,20 +427,22 @@
if (swipeInProgress)
return;
this.lastPressedKey.classList.remove('active');
- if (this.lastPressedKey.char != event.target.char)
- return;
- if (repeatKey.key == event.target) {
- repeatKey.cancel();
- return;
- }
+ // Changes keyset if necessary.
var toKeysetId = detail.toKeyset;
// Keyset transition key. This is needed to transition from upper
- // to lower case when we are not in caps mode.
+ // to lower case when we are not in caps mode, as well as when
+ // we're ending chording.
if (toKeysetId) {
this.keyset = toKeysetId;
this.querySelector('#' + this.layout + '-' + this.keyset).nextKeyset =
detail.nextKeyset;
}
+ if (this.lastPressedKey.charValue != event.target.charValue)
+ return;
+ if (repeatKey.key == event.target) {
+ repeatKey.cancel();
+ return;
+ }
var toLayoutId = detail.toLayout;
// Layout transition key.
if (toLayoutId)
diff --git a/ui/keyboard/resources/elements/kb-shift-key.html b/ui/keyboard/resources/elements/kb-shift-key.html
index 686a59c..bb874f0 100644
--- a/ui/keyboard/resources/elements/kb-shift-key.html
+++ b/ui/keyboard/resources/elements/kb-shift-key.html
@@ -21,7 +21,8 @@
PRESSED: "pressed", // Key-down on shift key.
LOCKED: "locked", // Key is capslocked.
UNLOCKED: "unlocked", // Default state.
- TAPPED: "tapped" // Key-down followed by key-up.
+ TAPPED: "tapped", // Key-down followed by key-up.
+ CHORDING: "chording" // Key-down followed by other keys.
};
/**
@@ -49,7 +50,11 @@
up: function(event) {
if (state == KEY_STATES.PRESSED) {
state = KEY_STATES.TAPPED;
- // TODO(rsadam@): Add chording logic here.
+ } else if (state == KEY_STATES.CHORDING) {
+ // Resets shift state.
+ state = KEY_STATES.UNLOCKED;
+ // TODO(rsadam@): Only end chording if the key-up is on the same
+ // shift key that started the chording.
}
this.super();
},
@@ -66,9 +71,10 @@
state = KEY_STATES.UNLOCKED;
break;
case KEY_STATES.PRESSED:
+ case KEY_STATES.CHORDING:
// We pressed another shift key at the same time,
// so ignore second press.
- break;
+ return;
default:
console.error("Undefined shift key state: " + state);
break;
@@ -113,13 +119,13 @@
* A control key is defined as one of shift, control or alt.
*/
onNonControlKeyDown: function() {
- // TODO(rsadam@): add logic for chording here.
switch (state) {
case (KEY_STATES.TAPPED):
state = KEY_STATES.UNLOCKED;
break;
case (KEY_STATES.PRESSED):
- // Enter chording mode. First disable longpress timer.
+ state = KEY_STATES.CHORDING;
+ // Disable longpress timer.
clearTimeout(this.shiftLongPressTimer);
break;
default:
@@ -155,6 +161,11 @@
detail.toKeyset = this.upperCaseKeysetId;
detail.nextKeyset = this.lowerCaseKeysetId;
break;
+ case(KEY_STATES.CHORDING):
+ detail.toKeyset = this.lowerCaseKeysetId;
+ break;
+ default:
+ break;
}
return detail;
},