A keyboard configuration for your motion.
- macOS
- Currently, sendKeyStroke.ts is dependend on macOS
- Welcome to Pull Request for supporting another platform
- web camera
- Bind keystroke to your motion
- Support gesture like π βοΈ
- Configuration by JavaScript
~/.config/motion-key/motion-key.config.js
- Download a binary from the latest releases
- Install app
Additional installation steps on macOS:
- Select
motion-key.app
- Open context menu and Click "Open"
motion-key.app
- Accessibility
- use accessibility permission to get
activeWindow
object activeWindow
includes active app info like bundle.id, url, title.
- use accessibility permission to get
- Screen Recording
- use Screen Recording permission to use web camera
You can write config file in ~/.config/motion-key/motion-key.config.js
.
Config location:
~/.config/motion-key/motion-key.config.js
You can control reaction for pixel diffs:
module.exports = ({ type, activeWindow, payload }) => {
if (type === "PixelChangeAction") {
// ignore diffs less than 5% of capture
if (payload.diffPercent < 5) {
return;
}
return {
key: "ArrowDown"
};
} else if (type === "GestureAction") {
return {
key: "ArrowUp"
};
}
}
You can change the config for each application:
const muPdf = ({ type }) => {
if (type === "PixelChangeAction") {
return {
key: "j"
}
} else if (type === "GestureAction") {
return {
key: "k"
}
}
};
module.exports = ({ type, activeWindow, payload }) => {
const bundleId = activeWindow?.owner?.bundleId;
if (bundleId === 'info.efcl.mu-pdf-viewer') {
return muPdf({ type });
}
if (type === "PixelChangeAction") {
return {
key: "ArrowDown"
}
} else if (type === "GestureAction") {
return {
key: "ArrowUp"
}
}
}
You can set key
for each Gesture:
module.exports = ({ type, activeWindow, payload }) => {
if (type === "PixelChangeAction") {
return {
key: "ArrowDown"
}
} else if (type === "GestureAction") {
if (payload.type === "π") {
return { key: "ArrowUp" }
}
if (payload.type === "βοΈ") {
return { key: "ArrowRight" }
}
}
}
You can set nextActionIntervalMs
to throttle keys.
motion-key ignore actions until the passage of nextActionIntervalMs
.
module.exports = ({ type, activeWindow, payload }) => {
if (type === "PixelChangeAction") {
return {
key: "ArrowDown",
nextActionIntervalMs: 5 * 1000
}
} else if (type === "GestureAction") {
return {
key: "ArrowUp",
nextActionIntervalMs: 5 * 1000
}
}
}
For more details, see Config.ts.
Only work on Kindle.app
const kindle = ({ type, payload }) => {
if (type === "PixelChangeAction") {
// large motion to next page
if (payload.diffPercent < 10) {
return;
}
return {
key: "Space"
}
} else if (type === "GestureAction") {
// π next page
if (payload.type === "π") {
return { key: "Space" }
}
// βοΈ prev page
if (payload.type === "βοΈ") {
return { key: "Space", modifier: { "shift": true } }
}
}
};
module.exports = ({ type, activeWindow, payload }) => {
const bundleId = activeWindow?.owner?.bundleId;
if (bundleId === "com.amazon.Kindle") {
return kindle({ type, payload })
}
}
npm version {patch,minor,major}
git push --tags
- Fork it!
- Create your feature branch:
git checkout -b my-new-feature
- Commit your changes:
git commit -am 'Add some feature'
- Push to the branch:
git push origin my-new-feature
- Submit a pull request :D
MIT