aboutsummaryrefslogtreecommitdiff
path: root/src/tools/keycode-info/keycode-info.vue
blob: 19d48df071cb1e0273b1454fb12afdafa83cb13d (plain) (blame)
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
<script setup lang="ts">
import { useEventListener } from '@vueuse/core';

import InputCopyable from '../../components/InputCopyable.vue';

const event = ref<KeyboardEvent>();

useEventListener(document, 'keydown', (e) => {
  event.value = e;
});

const fields = computed(() => {
  if (!event.value) {
    return [];
  }

  return [
    {
      label: 'Key :',
      value: event.value.key,
      placeholder: 'Key name...',
    },
    {
      label: 'Keycode :',
      value: String(event.value.keyCode),
      placeholder: 'Keycode...',
    },
    {
      label: 'Code :',
      value: event.value.code,
      placeholder: 'Code...',
    },
    {
      label: 'Location :',
      value: String(event.value.location),
      placeholder: 'Code...',
    },

    {
      label: 'Modifiers :',
      value: [
        event.value.metaKey && 'Meta',
        event.value.shiftKey && 'Shift',
        event.value.ctrlKey && 'Ctrl',
        event.value.altKey && 'Alt',
      ]
        .filter(Boolean)
        .join(' + '),
      placeholder: 'None',
    },
  ];
});
</script>

<template>
  <div>
    <c-card style="text-align: center; padding: 40px 0; margin-bottom: 26px">
      <n-h2 v-if="event">
        {{ event.key }}
      </n-h2>
      <n-text strong depth="3">
        Press the key on your keyboard you want to get info about this key
      </n-text>
    </c-card>

    <n-input-group v-for="({ label, value, placeholder }, i) of fields" :key="i" style="margin-bottom: 5px">
      <n-input-group-label style="flex: 0 0 150px">
        {{ label }}
      </n-input-group-label>
      <InputCopyable :value="value" readonly :placeholder="placeholder" />
    </n-input-group>
  </div>
</template>
better Unnamed repository; edit this file 'description' to name the repository.
aboutsummaryrefslogtreecommitdiff
path: root/docs/guides/write-file (unfollow)
AgeCommit message (Expand)AuthorFilesLines
2023-08-31insert `enumerable: true` when neededGravatar Dylan Conway 2-11/+120
2023-08-31`bun install` correctly join dependency URLs (#4421)Gravatar Julian 6-64/+243
2023-08-31get name if not provided in `FormData.append` (#4434)Gravatar Dylan Conway 4-5/+45
2023-08-31export non-enumerable valuesGravatar Dylan Conway 2-4/+79
2023-08-31Fix vscode debug terminalGravatar Ashcon Partovi 1-21/+0