A library that tracks browser keyboard focus state that powers tabster
Перейти к файлу
Oleksandr Fediashov 5c65d0d010
chore: setup Playwright & add base test (#60)
2023-12-21 10:41:29 +01:00
.github/workflows chore: setup Playwright & add base test (#60) 2023-12-21 10:41:29 +01:00
.ladle chore: setup Playwright & add base test (#60) 2023-12-21 10:41:29 +01:00
.vscode add format on save 2021-12-02 08:35:16 +01:00
bundle-size Adds @fluentui/bundle-size tool 2021-11-26 16:05:26 +01:00
src chore: setup Playwright & add base test (#60) 2023-12-21 10:41:29 +01:00
tests chore: setup Playwright & add base test (#60) 2023-12-21 10:41:29 +01:00
.browserslistrc IE11 EOL and packaging changes 2021-11-29 10:29:44 +01:00
.eslintrc.json format 2021-12-02 08:01:06 +01:00
.gitignore chore: setup Playwright & add base test (#60) 2023-12-21 10:41:29 +01:00
.npmignore format 2021-12-02 08:01:06 +01:00
.nvmrc Adds lockfile (#7) 2021-11-26 12:03:14 -03:00
.prettierignore revert to single rolltup 2021-12-02 08:00:26 +01:00
.prettierrc.json init(keyborg): Moves `keyborg` code from `tabster` repo 2021-11-18 10:26:29 +01:00
CODEOWNERS chore: setup CODEOWNERS (#57) 2023-12-20 16:41:03 +01:00
CODE_OF_CONDUCT.md CODE_OF_CONDUCT.md committed 2021-11-18 00:41:19 -08:00
CredScanSuppressions.json format 2023-12-19 19:58:49 +00:00
LICENSE LICENSE committed 2021-11-18 00:41:19 -08:00
README.md Update README.md 2021-11-18 18:58:46 +01:00
SECURITY.md init(keyborg): Moves `keyborg` code from `tabster` repo 2021-11-18 10:26:29 +01:00
azure-pipelines.yml chore: Update release pipeline to be compliant 2023-12-19 18:07:18 +00:00
monosize.config.mjs chore: switch to tsup (#58) 2023-12-20 17:42:29 +01:00
package-lock.json chore: setup Playwright & add base test (#60) 2023-12-21 10:41:29 +01:00
package.json chore: setup Playwright & add base test (#60) 2023-12-21 10:41:29 +01:00
playwright.config.ts chore: setup Playwright & add base test (#60) 2023-12-21 10:41:29 +01:00
tsconfig.json chore: setup Playwright & add base test (#60) 2023-12-21 10:41:29 +01:00
tsup.config.mjs chore: switch to tsup (#58) 2023-12-20 17:42:29 +01:00
vite.config.mts chore: setup Playwright & add base test (#60) 2023-12-21 10:41:29 +01:00

README.md

Keyborg ⌨️🤖

Keyborg is a library that tracks the state of current keyboard input on a web page through focus events.

It does not do anything invasive to the DOM but provides an event subscription system that allows users to choose how they want to react to changes in focus.

Getting started

Installation

# NPM
npm install --save keyborg
# Yarn
yarn add keyborg

Usage

import { createKeyborg } from "keyborg";

// initializes keyborg on the current window
const keyborg = createKeyborg(window);

// This is called every time the keyboard input state changes
const handler = (isUsingKeyboard) => {
  if (isUsingKeyboard) {
    document.body.setAttribute("data-is-keyboard", "true");
  } else {
    document.body.removeAttribute("data-is-keyboard");
  }
};

keyborg.subscribe(handler);
keyborg.unsubscribe(handler);

Contributing

Pretty simple currently, you only need to know about theese commands

  • npm install - install dependencies
  • npm run build - builds the library
  • npm run format:fix - runs prettier to format code
  • npm run lint:fix - runs eslint and fixes issues

This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.opensource.microsoft.com.

When you submit a pull request, a CLA bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.

Trademarks

This project may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft trademarks or logos is subject to and must follow Microsoft's Trademark & Brand Guidelines. Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship. Any use of third-party trademarks or logos are subject to those third-party's policies.