summaryrefslogtreecommitdiffstats
path: root/ui/keyboard/resources/elements/kb-shift-key.html
diff options
context:
space:
mode:
Diffstat (limited to 'ui/keyboard/resources/elements/kb-shift-key.html')
-rw-r--r--ui/keyboard/resources/elements/kb-shift-key.html63
1 files changed, 45 insertions, 18 deletions
diff --git a/ui/keyboard/resources/elements/kb-shift-key.html b/ui/keyboard/resources/elements/kb-shift-key.html
index 41e7b4b..ed9fdb8 100644
--- a/ui/keyboard/resources/elements/kb-shift-key.html
+++ b/ui/keyboard/resources/elements/kb-shift-key.html
@@ -4,7 +4,8 @@
-- found in the LICENSE file.
-->
-<polymer-element name="kb-shift-key" attributes="unlockedCase lockedCase state"
+<polymer-element name="kb-shift-key"
+ attributes="lowerCaseKeysetId upperCaseKeysetId"
class="shift dark" char="Shift" extends="kb-key">
<script>
(function () {
@@ -39,11 +40,11 @@
Polymer('kb-shift-key', {
/**
* Defines how capslock effects keyset transition. We always transition
- * from the unlockedCase to the lockedCase if capslock is on.
+ * from the lowerCaseKeysetId to the upperCaseKeysetId if capslock is on.
* @type {string}
*/
- unlockedCase: 'lower',
- lockedCase: 'upper',
+ lowerCaseKeysetId: 'lower',
+ upperCaseKeysetId: 'upper',
up: function(event) {
if (state == KEY_STATES.PRESSED) {
@@ -69,7 +70,7 @@
// so ignore second press.
break;
default:
- console.error("Undefined shift key state: " + this.state);
+ console.error("Undefined shift key state: " + state);
break;
}
// Trigger parent behaviour.
@@ -78,7 +79,7 @@
// Populate double click transition details.
var detail = {};
detail.char = this.char || this.textContent;
- detail.toKeyset = this.lockedCase;
+ detail.toKeyset = this.upperCaseKeysetId;
detail.nextKeyset = undefined;
detail.callback = this.onDoubleClick;
this.fire('enable-dbl', detail);
@@ -87,14 +88,14 @@
generateLongPressTimer: function() {
return this.asyncMethod(function() {
var detail = this.populateDetails();
- if (this.state == KEY_STATES.LOCKED) {
+ if (state == KEY_STATES.LOCKED) {
// We don't care about the longpress if we are already
// capitalized.
return;
} else {
- this.state = KEY_STATES.LOCKED;
- detail.shiftState = KEY_STATES.LOCKED;
- detail.toKeyset = this.lockedCase;
+ state = KEY_STATES.LOCKED;
+ detail.toKeyset = this.upperCaseKeysetId;
+ detail.nextKeyset = undefined;
}
this.fire('key-longpress', detail);
}, null, LONGPRESS_DELAY_MSEC);
@@ -107,23 +108,49 @@
state = KEY_STATES.LOCKED;
},
+ /**
+ * Notifies shift key that a non-control key was pressed down.
+ * 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.
+ clearTimeout(this.shiftLongPressTimer);
+ break;
+ default:
+ break;
+ }
+ },
+
+ /**
+ * Callback function for when a space is pressed after punctuation.
+ * @return {string} The keyset the keyboard should transition to.
+ */
+ onSpaceAfterPunctuation: function() {
+ state = KEY_STATES.TAPPED;
+ return this.upperCaseKeysetId;
+ },
+
populateDetails: function() {
var detail = this.super();
- detail.shiftState = this.state;
- switch(this.state) {
+ switch(state) {
case(KEY_STATES.LOCKED):
- detail.toKeyset = this.lockedCase;
+ detail.toKeyset = this.upperCaseKeysetId;
break;
case(KEY_STATES.UNLOCKED):
- detail.toKeyset = this.unlockedCase;
+ detail.toKeyset = this.lowerCaseKeysetId;
break;
case(KEY_STATES.PRESSED):
- detail.toKeyset = this.lockedCase;
- // detail.nextKeyset = this.unlockedCase;
+ detail.toKeyset = this.upperCaseKeysetId;
break;
case(KEY_STATES.TAPPED):
- detail.toKeyset = this.lockedCase;
- detail.nextKeyset = this.unlockedCase;
+ detail.toKeyset = this.upperCaseKeysetId;
+ detail.nextKeyset = this.lowerCaseKeysetId;
break;
}
return detail;