add keyDown

This commit is contained in:
Jade (Rose) Rowland 2025-01-02 22:12:48 -05:00
parent 2443aad01b
commit 3d162536aa
3 changed files with 32 additions and 2 deletions

View File

@ -138,6 +138,18 @@ pnpm --filter "./packages/**" publish --access public
To manually publish a single package, increase the version in the `package.json`, then run `pnpm publish`. To manually publish a single package, increase the version in the `package.json`, then run `pnpm publish`.
Important: Always publish with `pnpm`, as `npm` does not support overriding main files in `publishConfig`, which is done in all the packages. Important: Always publish with `pnpm`, as `npm` does not support overriding main files in `publishConfig`, which is done in all the packages.
## useful commands
```sh
#regenerate the test snapshots (ex: when updating or creating new pattern functions)
pnpm snapshot
#start the OSC server
pnpm run osc
#build the standalone version
pnpm tauri build
```
## Have Fun ## Have Fun
Remember to have fun, and that this project is driven by the passion of volunteers! Remember to have fun, and that this project is driven by the passion of volunteers!

View File

@ -644,7 +644,7 @@ export const always = register('always', function (func, pat) {
/** /**
* *
* Do something on a keypress, or array of keypresses * Do something on a keypress, or array of keypresses
* key name reference: https://developer.mozilla.org/en-US/docs/Web/API/UI_Events/Keyboard_event_key_values * * {@link https://developer.mozilla.org/en-US/docs/Web/API/UI_Events/Keyboard_event_key_values|Key name reference}
* *
* @name whenKey * @name whenKey
* @memberof Pattern * @memberof Pattern
@ -654,5 +654,21 @@ export const always = register('always', function (func, pat) {
*/ */
export const whenKey = register('whenKey', function (input, func, pat) { export const whenKey = register('whenKey', function (input, func, pat) {
return pat.when(isKeyDown(input), func); return pat.when(keyDown(input), func);
});
/**
*
* returns true when a key or array of keys is held
* {@link https://developer.mozilla.org/en-US/docs/Web/API/UI_Events/Keyboard_event_key_values|Key name reference}
*
* @name keyDown
* @memberof Pattern
* @returns Pattern
* @example
* keyDown("Control:j").pick([s("bd(5,8)"), s("cp(3,8)")])
*/
export const keyDown = register('keyDown', function (pat) {
return pat.fmap(isKeyDown);
}); });

View File

@ -4065,6 +4065,8 @@ exports[`runs examples > example "juxBy" example index 0 1`] = `
] ]
`; `;
exports[`runs examples > example "keyDown" example index 0 1`] = `[]`;
exports[`runs examples > example "lastOf" example index 0 1`] = ` exports[`runs examples > example "lastOf" example index 0 1`] = `
[ [
"[ 0/1 → 1/4 | note:c3 ]", "[ 0/1 → 1/4 | note:c3 ]",