Skip to content

Commit 3d16253

Browse files
committed
add keyDown
1 parent 2443aad commit 3d16253

File tree

3 files changed

+32
-2
lines changed

3 files changed

+32
-2
lines changed

CONTRIBUTING.md

+12
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,18 @@ pnpm --filter "./packages/**" publish --access public
138138
To manually publish a single package, increase the version in the `package.json`, then run `pnpm publish`.
139139
Important: Always publish with `pnpm`, as `npm` does not support overriding main files in `publishConfig`, which is done in all the packages.
140140

141+
142+
## useful commands
143+
```sh
144+
#regenerate the test snapshots (ex: when updating or creating new pattern functions)
145+
pnpm snapshot
146+
147+
#start the OSC server
148+
pnpm run osc
149+
150+
#build the standalone version
151+
pnpm tauri build
152+
```
141153
## Have Fun
142154

143155
Remember to have fun, and that this project is driven by the passion of volunteers!

packages/core/signal.mjs

+18-2
Original file line numberDiff line numberDiff line change
@@ -644,7 +644,7 @@ export const always = register('always', function (func, pat) {
644644
/**
645645
*
646646
* Do something on a keypress, or array of keypresses
647-
* key name reference: https://developer.mozilla.org/en-US/docs/Web/API/UI_Events/Keyboard_event_key_values
647+
* * {@link https://developer.mozilla.org/en-US/docs/Web/API/UI_Events/Keyboard_event_key_values|Key name reference}
648648
*
649649
* @name whenKey
650650
* @memberof Pattern
@@ -654,5 +654,21 @@ export const always = register('always', function (func, pat) {
654654
*/
655655

656656
export const whenKey = register('whenKey', function (input, func, pat) {
657-
return pat.when(isKeyDown(input), func);
657+
return pat.when(keyDown(input), func);
658+
});
659+
660+
/**
661+
*
662+
* returns true when a key or array of keys is held
663+
* {@link https://developer.mozilla.org/en-US/docs/Web/API/UI_Events/Keyboard_event_key_values|Key name reference}
664+
*
665+
* @name keyDown
666+
* @memberof Pattern
667+
* @returns Pattern
668+
* @example
669+
* keyDown("Control:j").pick([s("bd(5,8)"), s("cp(3,8)")])
670+
*/
671+
672+
export const keyDown = register('keyDown', function (pat) {
673+
return pat.fmap(isKeyDown);
658674
});

test/__snapshots__/examples.test.mjs.snap

+2
Original file line numberDiff line numberDiff line change
@@ -4065,6 +4065,8 @@ exports[`runs examples > example "juxBy" example index 0 1`] = `
40654065
]
40664066
`;
40674067

4068+
exports[`runs examples > example "keyDown" example index 0 1`] = `[]`;
4069+
40684070
exports[`runs examples > example "lastOf" example index 0 1`] = `
40694071
[
40704072
"[ 0/1 → 1/4 | note:c3 ]",

0 commit comments

Comments
 (0)