# @sofie-automation/sorensen

> A modern, i18n-friendly hotkey library for the Web

Latest version **1.5.11** (published 2025-04-15) · MIT license · 0 weekly downloads

## Install

```sh
npm install @sofie-automation/sorensen
pnpm add @sofie-automation/sorensen
yarn add @sofie-automation/sorensen
bun add @sofie-automation/sorensen
```

## Health

**Score 45/100 (D)** — status: stable.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: stale.

## Facts

| | |
|---|---|
| Version | 1.5.11 |
| Published | 2025-04-15 |
| First published | 2021-08-19 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 64.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 9 |
| Author | Jan Starzak <jan.starzak@nrk.no> |
| Maintainers | nytamin, nrk-sofie-ci |
| Keywords | keyboard, browser, shortcuts, combo, hotkey, user interface, keyboard api, web platform, i18n, keyboard layout |

## Links

- npm: https://www.npmjs.com/package/@sofie-automation/sorensen
- Repository: https://github.com/nrkno/sorensen
- Homepage: https://nrkno.github.io/sorensen/
- Issues: https://github.com/nrkno/sorensen/issues
- npm.io page: https://npm.io/package/@sofie-automation/sorensen

## Alternatives

- [@opentelemetry/exporter-zipkin](https://npm.io/package/@opentelemetry/exporter-zipkin.md) — 14.8M weekly downloads
- [pusher-js](https://npm.io/package/pusher-js.md) — 2.0M weekly downloads
- [browserify](https://npm.io/package/browserify.md) — 1.7M weekly downloads
- [sqs-consumer](https://npm.io/package/sqs-consumer.md) — 1.7M weekly downloads
- [@sanity/eventsource](https://npm.io/package/@sanity/eventsource.md) — 930.8K weekly downloads

## Recent versions

- 1.5.11 (latest) — 2025-04-15
- 1.5.11-nightly-main-20251020-171007-9ecdd80 (nightly) — 2025-10-20
- 1.1.0 (hotfix) — 2021-08-19
- 1.5.10 — 2025-04-15
- 1.5.8 — 2024-10-23
- 1.5.0 — 2024-10-22
- 1.4.3 — 2024-08-12
- 1.4.2 — 2022-05-05
- 1.4.1 — 2022-04-08
- 1.4.1-nightly-latest-20220405-113846-512a75b.0 — 2022-04-06
- 1.4.0 — 2022-04-06
- 1.3.2 — 2022-03-16
- 1.3.1 — 2022-03-02
- 1.3.0 — 2022-02-16
- 1.2.0 — 2021-09-14
- … 3 more at https://npm.io/package/@sofie-automation/sorensen/versions

## README

Sørensen
=========

Sørensen is a modern, i18n-friendly hotkey library for the Web. By *modern*, we mean that it uses the
`KeyboardEvent.code` property for matching keys. That means that physical keys, as opposed to the
character produced by the key, is used for defining key bindings. Other `KeyboardEvent` properties tend to be very
flaky, because they can change depending on the Keyboard Mapping used. By *i18n-friendly*, we mean that it
provides utility methods that use the Keyboard Map API to convert between key `code` values and strings to be
presented to the user, such as converting a `KeyQ` value to `A` on a French keyboard, and then converting `Z` to `KeyW`.

Install
-------
Just install the library using your package manager of choice. Sørensen has no external dependenices, but it assumes
a reasonably modern browser, as it uses ES7 features.

```
npm i --save @sofie-automation/sorensen
```
or:

```
yarn add @sofie-automation/sorensen
```

Use
---

```javascript
import sorensen from '@sofie-automation/sorensen'
await sorensen.init()
sorensen.bind('Tab+KeyT', (e) => {
	// Sorensen extends the KeyboardEvent object with `comboChordCodes` and `comboCodes`
	console.log(e)
	e.preventDefault()
}, {
	ordered: true,
	exclusive: true
})
```

For a comprehensive list of possible KeyboardEvent code values and their corresponding keys see [KeyboardEvent: code values](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/code/code_values) on MDN.

Additionally, Sørensen allows special, "virtual" codes, for conveniance when using modifiers and the Enter key. These are:

| Virtual Code | Matching real Codes                                                               |
| ------------ | --------------------------------------------------------------------------------- |
| `Shift`      | `ShiftLeft`, `ShiftRight`                                                         |
| `Control`    | `ControlLeft`, `ControlRight`                                                     |
| `Ctrl`       | `ControlLeft`, `ControlRight`                                                     |
| `Alt`        | `AltLeft`, `AltRight`                                                             |
| `Meta`       | `MetaLeft`, `MetaRight`                                                           |
| `AnyEnter`   | `Enter`, `NumpadEnter`                                                            |
| `Option`     | `AltLeft`, `AltRight`                                                             |
| `Command`    | `OSLeft`, `OSRight`                                                               |
| `Windows`    | `OSLeft`, `OSRight`                                                               |
| `Accel`      | on a Mac-like system: `OSLeft`, `OSRight`, others: `ControlLeft`, `ControlRight`  |

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