1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
7 * The background image to display on this key. Does not display an
8 * image if this is the empty string.
14 * The background image size to use if an image is specified. The size
15 * is provided as a string, for example, "50%".
21 * Key codes have been deprecated in DOM3 key events, but are required
22 * for legacy web content. The key codes depend on the position of the
23 * key on the keyboard and is independent of which modifier keys (shift,
24 * alt, ...) are active.
25 * @type {number|undefined}
30 * Name of the key as defined in the DOM3 specification for key events.
31 * Like the keyCode, the keyName is independent of the state of the
33 * @type {string|undefined}
38 * Whether the shift key is pressed when producing the key value.
44 * The sound to play when this key is pressed.
50 * Whether the key can be stretched to accomodate pixel rounding errors.
55 * Weighting to use for layout in order to properly size the key.
56 * Keys with a high weighting are wider than normal keys.
59 weight
: DEFAULT_KEY_WEIGHT
,
62 * Called when the image attribute changes. This is used to set the
63 * background image of the key.
64 * TODO(rsadam): Remove when polymer {{}} syntax regression is fixed.
66 imageChanged: function() {
68 this.$.key
.style
.backgroundImage
= "none";
70 // If no extension provided, default to svg.
72 this.image
.split('.').length
> 1 ? this.image
: this.image
+ ".svg";
73 this.$.key
.style
.backgroundImage
=
74 "url(images/" + image
+ ")";
79 * Returns a subset of the key attributes.
80 * @param {string} caller The id of the function that called
82 * @return {Object} Mapping of attributes for the key element.
84 populateDetails: function(caller
) {
85 var details
= this.super([caller
]);
86 details
.keyCode
= this.keyCode
;
87 details
.keyName
= this.keyName
;
88 details
.shiftModifier
= this.shiftModifier
;
89 details
.sound
= this.sound
;
95 Polymer('kb-abc-key', {
96 populateDetails: function(caller
) {
97 var detail
= this.super([caller
]);
100 detail
.relegateToShift
= true;
110 Polymer('kb-hide-keyboard-key', {
111 up: function(event
) {