# keyboard-layout

> Read and observe the current keyboard layout on OS X.

Latest version **2.0.17** (published 2020-10-14) · 0 weekly downloads

## Install

```sh
npm install keyboard-layout
pnpm add keyboard-layout
yarn add keyboard-layout
bun add keyboard-layout
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.17 |
| Published | 2020-10-14 |
| First published | 2014-09-22 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 63.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | yes |
| GitHub stars | 63 |
| Maintainers | benogle, nathansobo, binarymuse, smashwilson, kevinsawicki, maxbrunsfeld, zcbenz, as-cii, daviwil, atom-team |

## Links

- npm: https://www.npmjs.com/package/keyboard-layout
- Repository: https://github.com/atom/keyboard-layout
- Homepage: https://github.com/atom/keyboard-layout#readme
- Issues: https://github.com/atom/keyboard-layout/issues
- npm.io page: https://npm.io/package/keyboard-layout

## Dependencies (2)

- [nan](https://npm.io/package/nan.md) ^2.13.2
- [event-kit](https://npm.io/package/event-kit.md) ^2.0.0

## Recent versions

- 2.0.17 (latest) — 2020-10-14
- 2.0.16 — 2019-05-24
- 2.0.15-0 — 2019-05-20
- 2.0.15 — 2019-01-30
- 2.0.14 — 2018-09-06
- 2.0.13 — 2017-07-10
- 2.0.12 — 2017-04-12
- 2.0.11 — 2017-02-13
- 2.0.10 — 2017-01-06
- 2.0.9 — 2017-01-05
- 2.0.8 — 2017-01-04
- 2.0.7 — 2016-11-23
- 2.0.6 — 2016-11-21
- 2.0.5 — 2016-11-21
- 2.0.4 — 2016-11-21
- … 24 more at https://npm.io/package/keyboard-layout/versions

## README

# keyboard-layout
[![macOS Build Status](https://travis-ci.org/atom/keyboard-layout.svg?branch=master)](https://travis-ci.org/atom/keyboard-layout)
[![Windows Build status](https://ci.appveyor.com/api/projects/status/rk8wooeyh689apgd/branch/master?svg=true)](https://ci.appveyor.com/project/Atom/keyboard-layout)
[![Dependency Status](https://david-dm.org/atom/keyboard-layout/status.svg)](https://david-dm.org/atom/keyboard-layout)

Read and observe the current keyboard layout.

To get the current keyboard layout, call `getCurrentKeyboardLayout`. It returns
the string identifier of the current layout based on the value returned by the
operating system.

```js
const KeyboardLayout = require('keyboard-layout')
KeyboardLayout.getCurrentKeyboardLayout() // => "com.apple.keylayout.Dvorak"
```

If you want to watch for layout changes, use `onDidChangeCurrentKeyboardLayout`
or `observeCurrentKeyboardLayout`. They work the same, except
`observeCurrentKeyboardLayout` invokes the given callback immediately with the
current layout value and then again next time it changes, whereas
`onDidChangeCurrentKeyboardLayout` only invokes the callback on the next
change.

```js
const KeyboardLayout = require('keyboard-layout')
subscription = KeyboardLayout.observeCurrentKeyboardLayout((layout) => console.log(layout))
subscription.dispose() // to unsubscribe later
```

To return characters for various modifier states based on a DOM 3
`KeyboardEvent.code` value and the current system keyboard layout, use
`getCurrentKeymap()`:

```js
const KeyboardLayout = require('keyboard-layout')
KeyboardLayout.getCurrentKeymap()['KeyS']
/*
On a US layout, this returns:
{
  unmodified: 's',
  withShift: 'S',
  withAltGraph: 'ß',
  withShiftAltGraph: 'Í'
}
*/
```

---
_Source: https://npm.io/package/keyboard-layout · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
