Discussion:
KeyActions that require two keys?
carltesta
2014-10-13 13:08:58 UTC
Permalink
Hi Everyone,

I was wondering if anyone might have any advice on how to create keyActions
that require multiple keys to be pressed? Or one key acting as a latch that
requires an additional key to determine intent?

For example, holding down key "F" would tell SC I want to change the
feedback level, then hitting keys 1, 2, 3, or 4 would tell SC which feedback
I want to change. Any ideas?

Thank You,
Carl





--
View this message in context: http://new-supercollider-mailing-lists-forums-use-these.2681727.n2.nabble.com/KeyActions-that-require-two-keys-tp7613986.html
Sent from the SuperCollider Users New (Use this!!!!) mailing list archive at Nabble.com.

_______________________________________________
sc-users mailing list

info (subscription, etc.): http://www.beast.bham.ac.uk/research/sc_mailing_lists.shtml
archive: http://www.listarc.bham.ac.uk/marchives/sc-users/
search: http://www.listarc.bham.ac.uk/lists/sc-users/search/
Daniel Mayer
2014-10-13 14:31:43 UTC
Permalink
Post by carltesta
Hi Everyone,
I was wondering if anyone might have any advice on how to create keyActions
that require multiple keys to be pressed? Or one key acting as a latch that
requires an additional key to determine intent?
For example, holding down key "F" would tell SC I want to change the
feedback level, then hitting keys 1, 2, 3, or 4 would tell SC which feedback
I want to change. Any ideas?
Thank You,
Carl
Modifier keys would be a standard option.

But you could also write a data structure (could be a class)
that keeps track of pressed keys by keyDown- and -UpActions,
and that you could assign custom actions for combos.

Maybe somebody has already done that with earlier Document versions ?
Currently Document is in development in the 3.7 branch.

Greetings

Daniel

-----------------------------
www.daniel-mayer.at
-----------------------------



_______________________________________________
sc-users mailing list

info (subscription, etc.): http://www.beast.bham.ac.uk/research/sc_mailing_lists.shtml
archive: http://www.listarc.bham.ac.uk/marchives/sc-users/
search: http://www.listarc.bham.ac.uk/lists/sc-users/search/
Eli Fieldsteel
2014-10-13 14:43:23 UTC
Permalink
I asked a similar question back in this thread:

http://new-supercollider-mailing-lists-forums-use-these.2681727.n2.nabble.com/non-repeating-keyDownAction-when-key-is-held-td7609902.html

Though not the same issue, the solution (using a Set to keep a dynamic
collection of currently depressed keys) could easily be adapted to this
issue. Really, all you'd need to do is add conditional statements to take
your desired action(s) based on the keys in the Set, and the order in which
those keys are pressed.

Eli



--
View this message in context: http://new-supercollider-mailing-lists-forums-use-these.2681727.n2.nabble.com/KeyActions-that-require-two-keys-tp7613986p7613993.html
Sent from the SuperCollider Users New (Use this!!!!) mailing list archive at Nabble.com.

_______________________________________________
sc-users mailing list

info (subscription, etc.): http://www.beast.bham.ac.uk/research/sc_mailing_lists.shtml
archive: http://www.listarc.bham.ac.uk/marchives/sc-users/
search: http://www.listarc.bham.ac.uk/lists/sc-users/search/
carltesta
2014-10-14 11:45:07 UTC
Permalink
Thanks Everyone,

Yes, the Set is what I needed. Here is what I came up with.

Thanks,
Carl

(
~window = Window.new.front;
~keySet = Set[];
~window.view.keyDownAction_({
arg view, char, mod, uni, key;
case
{char == $t} {~keySet.add($t)}
{char == $l} {~keySet.add($l)}
{char == $p} {~keySet.add($p)}
{char == $m} {~keySet.add($m)}

{char == $a} {
case
{~keySet.includes($t)} {"T also pressed".postln}
{~keySet.includes($l)} {"L also pressed".postln}
{~keySet.includes($p)} {"P also pressed".postln}
{~keySet.includes($m)} {"M also pressed".postln}
}
});

~window.view.keyUpAction_({
arg view, char, mod, uni, key;
case
{char == $t} {~keySet.remove($t)}
{char == $l} {~keySet.remove($l)}
{char == $p} {~keySet.remove($p)}
{char == $m} {~keySet.remove($m)}
});
)




--
View this message in context: http://new-supercollider-mailing-lists-forums-use-these.2681727.n2.nabble.com/KeyActions-that-require-two-keys-tp7613986p7613999.html
Sent from the SuperCollider Users New (Use this!!!!) mailing list archive at Nabble.com.

_______________________________________________
sc-users mailing list

info (subscription, etc.): http://www.beast.bham.ac.uk/research/sc_mailing_lists.shtml
archive: http://www.listarc.bham.ac.uk/marchives/sc-users/
search: http://www.listarc.bham.ac.uk/lists/sc-users/search/

Loading...