2 -- Copyright 2013 The Chromium Authors. All rights reserved.
3 -- Use of this source code is governed by a BSD-style license that can be
4 -- found in the LICENSE file.
7 <polymer-element name="kb-key" extends="kb-key-base"
8 attributes="keyCode shiftModifier weight">
13 -webkit-box-flex: {{weight}};
17 <div id="key" pseudo="x-key" inverted?={{invert}}>
20 <div pseudo="x-hinttext" inverted?={{invert}}>{{hintText}}</div>
25 * Key codes have been deprecated in DOM3 key events, but are required
26 * for legacy web content. The key codes depend on the position of the
27 * key on the keyboard and is independent of which modifier keys (shift,
28 * alt, ...) are active.
29 * @type {number|undefined}
33 * Whether the shift key is pressed when producing the key value.
38 * Weighting to use for layout in order to properly size the key.
39 * Keys with a high weighting are wider than normal keys.
45 * Returns a subset of the key attributes.
46 * @param {string} caller The id of the function that called
48 * @return {Object} Mapping of attributes for the key element.
50 populateDetails: function(caller) {
51 var details = this.super([caller]);
52 details.keyCode = this.keyCode;
53 details.shiftModifier = this.shiftModifier;
61 <polymer-element name="kb-abc-key" class="symbol dark" char="Invalid"
64 Polymer('kb-abc-key', {
65 populateDetails: function(caller) {
66 var detail = this.super([caller]);
69 detail.relegateToShift = true;
80 <polymer-element name="kb-hide-keyboard-key" class="hide-keyboard dark"
81 char="Invalid" extends="kb-key">
83 Polymer('kb-hide-keyboard-key', {
85 * Timer for a long press event which triggers the display of a keyboard
89 longPressTimer: undefined,
91 down: function(event) {
93 this.longPressTimer = this.asyncMethod(function() {
94 if (self.longPressTimer) {
95 clearTimeout(self.longPressTimer);
96 self.longPressTimer = undefined;
98 left: this.offsetLeft,
100 width: this.clientWidth,
102 this.fire('show-options', details);
104 }, null, LONGPRESS_DELAY_MSEC);
107 up: function(event) {
108 if (this.longPressTimer) {
109 clearTimeout(this.longPressTimer);
111 this.longPressTimer = undefined;