summaryrefslogtreecommitdiff
path: root/chromium/ui/keyboard/resources/elements/kb-key.html
blob: d9bf0776750bf1a50df96f162809200c41573bed (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
<!--
  -- Copyright 2013 The Chromium Authors. All rights reserved.
  -- Use of this source code is governed by a BSD-style license that can be
  -- found in the LICENSE file.
  -->

<polymer-element name="kb-key" extends="kb-key-base"
    attributes="keyCode shiftModifier weight">
  <template>
    <style>
      @host {
        * {
          -webkit-box-flex: {{weight}};
        }
      }
    </style>
    <div id="key" pseudo="x-key" inverted?={{invert}}>
      <content></content>
    </div>
    <div pseudo="x-hinttext" inverted?={{invert}}>{{hintText}}</div>
  </template>
  <script>
    Polymer('kb-key', {
      /**
       * Key codes have been deprecated in DOM3 key events, but are required
       * for legacy web content. The key codes depend on the position of the
       * key on the keyboard and is independent of which modifier keys (shift,
       *  alt, ...) are active.
       * @type {number|undefined}
       */
      keyCode: undefined,
      /**
       * Whether the shift key is pressed when producing the key value.
       * @type {boolean}
       */
      shiftModifier: false,
      /**
       * Weighting to use for layout in order to properly size the key.
       * Keys with a high weighting are wider than normal keys.
       * @type {number}
       */
      weight: 1,

      /**
       * Returns a subset of the key attributes.
       * @return {Object} Mapping of attributes for the key element.
       */
      populateDetails: function() {
        var details = this.super();
        details.keyCode = this.keyCode;
        details.shiftModifier = this.shiftModifier;
        return details;
      },
    });
  </script>
</polymer-element>

<!-- Special keys -->

<!--
  -- TODO(kevers): Rip this out if and when we are done implementing the proper
  -- layout switcher.
  -->
<polymer-element name="kb-layout-selector" class="layout-selector dark" char="Invalid"
    extends="kb-key">
  <script>
    Polymer('kb-layout-selector', {
      toLayout: 'qwerty'
    });
  </script>
</polymer-element>

<polymer-element name="kb-hide-keyboard-key" class="hide-keyboard dark" char="Invalid"
    extends="kb-key">
  <script>
    Polymer('kb-hide-keyboard-key', {
      down: function(event) {},
      up: function(event) {
        hideKeyboard();
      }
    });
  </script>
</polymer-element>