GithubHelp home page GithubHelp logo

amekusa / karabinerge Goto Github PK

View Code? Open in Web Editor NEW
6.0 2.0 0.0 781 KB

Karabiner Elements complex modifications generator

License: MIT License

JavaScript 100.00%
accessibility karabiner keyboard macos productivity remap shortcuts

karabinerge's Introduction

KARABINERGE

NPM Version NPM License

Karabiner-Elements complex modifications generator

๐Ÿ“˜ Full Documentation

What this is

Karabinerge provides useful functions and classes that help you to programmatically generate complex modifications of Karabiner-Elements in a simple and short syntax.

Tired of tinkering with JSON by your hand? This is for you.

How to install

npm i --save karabinerge

# as global package
npm i -g karabinerge

How to use

// example.js
import {RuleSet, key} from 'karabinerge'; // ES6
const {RuleSet, key} = require('karabinerge'); // CJS

let rules = new RuleSet('My Rules');

rules.add('control + H to backspace')
  .remap({
    from: key('h', 'control'),
    to:   key('delete_or_backspace')
  });

rules.out(); // output JSON to stdout

Run it on terminal:

node example.js > example.json

Result (example.json):

{
  "title": "My Rules",
  "rules": [
    {
      "description": "control + H to backspace",
      "manipulators": [
        {
          "type": "basic",
          "from": {
            "key_code": "h",
            "modifiers": {
              "mandatory": [
                "control"
              ]
            }
          },
          "to": [
            {
              "key_code": "delete_or_backspace"
            }
          ]
        }
      ]
    }
  ]
}

More examples

import {RuleSet, key} from 'karabinerge';
let rules = new RuleSet('My Rules');

rules.add('command + H/J/K/L to arrow keys')
  .remap({
    from: key('h', 'command'),
    to:   key('left_arrow')
  })
  .remap({
    from: key('j', 'command'),
    to:   key('down_arrow')
  })
  .remap({
    from: key('k', 'command'),
    to:   key('up_arrow')
  })
  .remap({
    from: key('l', 'command'),
    to:   key('right_arrow')
  });

rules.out();

Result:

{
  "title": "My Rules",
  "rules": [
    {
      "description": "command + H/J/K/L to arrow keys",
      "manipulators": [
        {
          "type": "basic",
          "from": {
            "key_code": "h",
            "modifiers": {
              "mandatory": [
                "command"
              ]
            }
          },
          "to": [
            {
              "key_code": "left_arrow"
            }
          ]
        },
        {
          "type": "basic",
          "from": {
            "key_code": "j",
            "modifiers": {
              "mandatory": [
                "command"
              ]
            }
          },
          "to": [
            {
              "key_code": "down_arrow"
            }
          ]
        },
        {
          "type": "basic",
          "from": {
            "key_code": "k",
            "modifiers": {
              "mandatory": [
                "command"
              ]
            }
          },
          "to": [
            {
              "key_code": "up_arrow"
            }
          ]
        },
        {
          "type": "basic",
          "from": {
            "key_code": "l",
            "modifiers": {
              "mandatory": [
                "command"
              ]
            }
          },
          "to": [
            {
              "key_code": "right_arrow"
            }
          ]
        }
      ]
    }
  ]
}

Real life examples

More details

See: ๐Ÿ“˜ Full Documentation


Karabinerge ยฉ 2022 Satoshi Soma (amekusa.com) Licensed under the MIT license

karabinerge's People

Contributors

amekusa avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.