Components

Khmer Keyboard

An on-screen Khmer keyboard that lights up the next key.

Install with one command, or copy the files

Preview

Type four words. The next key lights up, and your real keyboard works too, even without Khmer installed.

hello1 of 4

សួស្តី

Click here, then type on your keyboard

Install

pnpx sothearo add khmer-keyboard

It checks whether you use Vue, Nuxt or React, and adds only the files you need to your components folder, in khmer-keyboard/. They're yours to change.

Usage

Bind the text with v-model, and pass the word to type as target. Its next key lights up, Shift too when it's needed, and delete after a mistake. In Nuxt it's auto-imported, so you can skip the import.

App.vue
<script setup lang="ts">
import { ref } from "vue";
import KhmerKeyboard from "@/components/khmer-keyboard/KhmerKeyboard.vue";

const text = ref("");
</script>

<template>
  <KhmerKeyboard v-model="text" target="សួស្តី" latin />
</template>

Typing test

check compares what was typed with the target. It tells you if the text is right so far, if it's done, and which key comes next. Turn on capture while your test has focus, and real keys type Khmer even on a computer without a Khmer keyboard.

lesson.ts
import { check } from "@/components/khmer-keyboard/core";

check("សួស្តី", "សួ");
// { correct: true, done: false, next: { key: KeyS, shift: false } }

Props

PropTypeDefaultWhat it does
v-modelstring""The typed text. Keys add to it, delete removes the last character.
targetstringThe word to type. The key to press next lights up.
latinbooleanfalseShows the Latin letter in the corner of each key.
capturebooleanfalseReal keys type Khmer into v-model. Fields and shortcuts are left alone.

Events and slots

NameGives youWhen
@presstextA key types something.
@backspaceDelete is pressed.
#keyitem, text, hinted, pressedReplace what each key shows.

Customise

Every colour comes from the text colour, so the keyboard fits light and dark themes on its own. Change it with CSS variables, and style states with data attributes.

keyboard.css
[data-khmer-keyboard] {
  --khmer-keyboard-font: "Kantumruy Pro", sans-serif;
  --khmer-keyboard-gap: 6px;
  --khmer-keyboard-max-width: 560px;
}

[data-khmer-keyboard] [data-hint] {
  --khmer-keyboard-ink: #2f6fed;
}

Keys carry data-kind, data-hint and data-pressed, so you can target one kind of key or one state without new props.

Accessibility

  • Every key is a real button with a label, so screen readers say the character it types.
  • Keys don't take focus when clicked, so the text field keeps it.
  • Without capture, your physical keys only light up. The keyboard never changes what they type.
  • Motion turns off when the system asks for reduced motion.
Code by day, manga by night.2026