|
4 | 4 | <head>
|
5 | 5 | <meta charset="utf-8">
|
6 | 6 | <meta name="viewport" content="width=device-width">
|
7 |
| - <title>Hotkey Mapper Tool</title> |
| 7 | + <title>hotkey | Mapper Tool</title> |
8 | 8 | <link href="https://unpkg.com/@primer/css@^16.0.0/dist/primer.css" rel="stylesheet" />
|
9 | 9 | <script type="module" src="https://unpkg.com/@github/clipboard-copy-element@latest?module"></script>
|
10 |
| - <style> |
11 |
| - .copy { |
12 |
| - /* marg */ |
13 |
| - } |
14 |
| - </style> |
15 | 10 | </head>
|
16 | 11 |
|
17 | 12 | <body>
|
18 |
| - <div class="blankslate mx-auto col-12 col-md-8 col-lg-6"> |
19 |
| - <h1>Hotkey Code</h1> |
20 |
| - <p>Type your desired key combination on the keyboard to see the corresponding Hotkey string.</p> |
| 13 | + <div class="mx-auto my-3 col-12 col-md-8 col-lg-6"> |
| 14 | + <h1 id="app-name">Hotkey Code</h1> |
| 15 | + <p id="hint">Press a key combination to see the corresponding hotkey string.</p> |
21 | 16 | <div class="position-relative">
|
22 |
| - <clipboard-copy for="hotkey-code" class="position-absolute top-2 right-2"> |
23 |
| - <button aria-label="Copy to clipboard" class="btn"> |
24 |
| - <svg aria-hidden="true" role="img" class="StyledOcticon-uhnt7w-0 iIOaoH" viewBox="0 0 16 16" width="16" height="16" fill="currentColor" style="display:inline-block;user-select:none;vertical-align:text-bottom;overflow:visible"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg> |
25 |
| - </button> |
| 17 | + <input |
| 18 | + role="application" |
| 19 | + aria-roledescription="Input Capture" |
| 20 | + autofocus |
| 21 | + aria-labelledby="app-name" |
| 22 | + aria-describedby="hint" |
| 23 | + aria-live="assertive" |
| 24 | + aria-atomic="true" |
| 25 | + id="hotkey-code" |
| 26 | + class="border rounded-2 mt-2 p-6 f1 text-mono" |
| 27 | + style="width: 100%" |
| 28 | + /> |
| 29 | + |
| 30 | + <clipboard-copy for="hotkey-code" class="position-absolute bottom-2 right-2 btn"> |
| 31 | + Copy to clipboard |
26 | 32 | </clipboard-copy>
|
27 |
| - <div id="hotkey-code" class="border rounded-2 p-6 f1 text-mono overflow-auto"> </div> |
28 | 33 | </div>
|
29 | 34 | </div>
|
30 | 35 |
|
31 | 36 | <script type="module">
|
32 | 37 | // import {eventToHotkeyString} from '../dist/index.js'
|
33 |
| - import {eventToHotkeyString} from 'https://unpkg.com/@github/hotkey@latest?module'; |
34 |
| - const codeInput = document.getElementById('hotkey-code'); |
35 |
| - document.addEventListener('keydown', event => { |
36 |
| - const code = eventToHotkeyString(event); |
37 |
| - console.log(`Hotkey Code is: "${code}"`); |
38 |
| - codeInput.innerText = code; |
| 38 | + import {eventToHotkeyString} from 'https://unpkg.com/@github/hotkey@latest?module' |
| 39 | + |
| 40 | + document.getElementById('hotkey-code').addEventListener('keydown', event => { |
| 41 | + if (event.key === "Tab") |
| 42 | + return; |
| 43 | + |
39 | 44 | event.preventDefault();
|
40 | 45 | event.stopPropagation();
|
| 46 | + |
| 47 | + event.currentTarget.value = eventToHotkeyString(event); |
41 | 48 | })
|
42 | 49 | </script>
|
43 | 50 | </body>
|
|
0 commit comments