Skip to content

ocavue/keyboard-layout-map

Repository files navigation

keyboard-layout-map

NPM version

Utils for experimental Web KeyboardLayoutMap API.

Install

npm install keyboard-layout-map

Usage

Get the current keyboard layout.

import { getKeyboardLayout } from 'keyboard-layout-map'

const layout = await getKeyboardLayout()
//     ^: KeyboardLayoutMap | null

Identify the current keyboard layout.

import { identifyKeyboardLayout } from 'keyboard-layout-map'

const name = await identifyKeyboardLayout(layout)
//     ^: "US" | "French" | "German" | "LatinAmerican" ...

Get all supported keyboard layouts.

import * as layouts from 'keyboard-layout-map/layouts'

const ItalianLayout = layouts['Italian']
//     ^: KeyboardLayoutMap

const SlovakLayout = layouts['Slovak']
//     ^: KeyboardLayoutMap

License

MIT