Filtered keydown/up for Pd

Sun Jan 03 2010 21:41:43 GMT-0800 (Pacific Standard Time)

tags: pd puredata

Sometimes when I'm prototyping patches in Pd and working at a computer keyboard (without an external controller), I like to be able to quickly map keyboard keys to trigger events.

The vanilla key objects are fine ([key], [keyup], and [keyname]), but [keyname], in particular, likes to send redundant events when a key is held (due to key repeats). As a result, I created [keyonoff]:

keyonoff

This abstraction will take a given key (and an optional timeout duration) and will map a keypress onto a simple 1 or 0, while eliminating duplicates. In other words, when your desired key is pressed, it will output a 1 and will output a 0 iff a zero has been seen from [keyname] and no 1 has been seen within the filtering period. The default timeout period is 50ms, which is suitable for command-like actions, but will need tweaking for time-sensitive rhythmic work.

It's hosted with my other Pd objects, and you can simply download it directly here. Enjoy!