MCPcopy Create free account
hub / github.com/TanStack/hotkeys / render

Method render

examples/lit/held-keys/src/app.ts:54–143  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

52 render() {
53 const keys = this.heldKeys.value
54 const codes = this.heldCodes.value
55
56 return html`
57 <div class="app">
58 <header>
59 <h1>HeldKeysController</h1>
60 <p>
61 Returns an array of all currently pressed keys. Useful for
62 displaying key combinations or building custom shortcut recording.
63 </p>
64 </header>
65
66 <main>
67 <section class="demo-section">
68 <h2>Currently Held Keys</h2>
69 <div class="key-display">
70 ${
71 keys.length > 0
72 ? keys.map((key, index) => {
73 const code = codes[key]
74 return html`
75 ${index > 0 ? html`<span class="plus">+</span>` : null}
76 <kbd class="large">
77 ${this.formatForDisplay.format(
78 { key },
79 { useSymbols: true },
80 )}
81 ${
82 code && code !== key
83 ? html`<small class="code-label">
84 ${code}
85 </small>`
86 : null
87 }
88 </kbd>
89 `
90 })
91 : html`<span class="placeholder">Press any keys...</span>`
92 }
93 </div>
94 <div class="stats">Keys held: <strong>${keys.length}</strong></div>
95 </section>
96
97 <section class="demo-section">
98 <h2>Usage</h2>
99 <pre class="code-block">
100${`import { HeldKeysController } from '@tanstack/lit-hotkeys'
101
102class KeyDisplay extends LitElement {
103 private heldKeys = new HeldKeysController(this)
104
105 render() {
106 return html\`
107 <div>
108 Currently pressed: \${this.heldKeys.value.join(' + ') || 'None'}
109 </div>
110 \`
111 }

Callers

nothing calls this directly

Calls 1

formatForDisplayFunction · 0.85

Tested by

no test coverage detected