kakiyasu
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

Binds actions to keys for the input element selector provided. Useful when using square-bracket notation for adding furigana/yomigana readings.

https://user-images.githubusercontent.com/5191838/133937985-acd7fe0f-a39b-4d3d-94f3-5c952d331920.mov

Key Action
Escape Inserts "[]" at the current cursor position
Shift + Escape Inserts "()" at the current cursor position
Alt Inserts a space at the current cursor position

usage

const Kakiyasu = require("kakiyasu").default;
new Kakiyasu("#my-input-selector");

add additional actions

const Kakiyasu = require("kakiyasu").default;
new Kakiyasu("#my-input-selector", {
  "<event.key>": {
    text: "text to insert",
    offset: number
  }
});

where text is the text to insert, and offset is the offset back from the end of the inserted text, and is where the cursor will be placed. For example, for the default Escape action which inserts "[]", the offset is -1 in order to place the cursor inbetween the brackets.

If your new action is a combination of Shift + another key, the action key would become "<event.key>Shift", where event.key is the key property on the keydown event object.

The default actions are as follows and can be overridden:

const defaultActions = {
  Escape: {
    text: "[]",
    offset: -1,
  },
  EscapeShift: {
    text: "()",
    offset: -1,
  },
  Alt: {
    text: " ",
    offset: 0,
  },
};

Readme

Keywords

none

Package Sidebar

Install

npm i kakiyasu

Weekly Downloads

8

Version

1.0.0

License

Apache-2.0

Unpacked Size

25.7 kB

Total Files

6

Last publish

Collaborators

  • e-e