[PD] [key], [keyup] and operating system key reapat

Peter P. peterparker at fastmail.com
Wed May 4 07:56:26 CEST 2022


Dear oliver, dear list,

* oliver <oliver at klingt.org> [2022-05-03 18:05]:
> Peter P. wrote:
> > Dear Dan and everyone contributing to this issue,
> > 
> > I kinda felt this is a sensitive topic but was not aware of the amount
> > of frustrating work that has already gone into it. Every bit of it is
> > much appreciated, thank you and everyone a lot!
> > 
> > So if I would want to write a patch that uses the [key] and [keyup] objects to
> > work consistently on all three platforms, I would have to tell the user to
> > turn key repeat off in her operating system AND provide a means to
> > filter out repeating key ons (Win and OS X), correct?
> > 
> > In this case I happily deal with the current status.
> 
> Often key repetitions are desired, for example if i want to make a beautiful
> dividing line like this:
> 
> =======================================================================
Yes, this is without discussion and full of beauty. However for many Pd-related
requirements it is not.
 
> Maybe a safer approach would be to provide an abstraction that does the
> filtering depending on the OS.
I think there should be a vanilla way that works on all three OSes.
Thanks for pointing to your abstraction, it looks very sophisticated. I
have used the attached abstraction in the past to filter key repeats but
it did not work reliably. It would occasionally let single repeated
events pass through, and has to be tuned to the key repeat rate, as
there is a wait time. Futhermore these abstraction get hella complicated
if you depress multiple keys simultaneously.

cheersz, P
-------------- next part --------------
#N canvas 559 247 891 565 12;
#X text 13 13 Abstraction to detect keyboard actions without repeating
key presses.;
#X obj 154 173 tgl 15 0 empty empty down/up 17 7 0 10 -262144 -1 -1
0 1;
#X obj 125 201 bng 15 250 50 0 empty empty should_only_flash_once_on_down_or_up
17 7 0 10 -262144 -1 -1;
#X obj 36 420 timer;
#X obj 36 394 t b b;
#X obj 36 340 key;
#X obj 36 366 sel 71;
#X obj 36 445 moses 1;
#X floatatom 35 474 5 0 0 1 msec - -;
#X obj 35 500 print myComputersRepeatRate;
#X text 139 339 When you press and hold a key on your computers keyboard
\, most operating systems will repeat this keypress automatically \,
mimicking old typewriters. This can be an obstacle to detect key-down
and key-up reliably. Use the patch to the left to estimate the longest
intervall in milliseconds of such repeats while keeping a single key
depressed. The first argument of [keyhold] should be slightly larger
than this interval.;
#X obj 125 146 keyhold 60 G;
#X text 460 163 2.argument: Symbol to indicate the key to filter.;
#X text 459 90 1.argument: Interval time (msec) to block key repeats.
Will vary for different operating systems and its user settings. See
patch below for information how to set for your computer.;
#X text 26 247 This will detect key downs and ups for capital letter
'G' while blocking key repeats that happen faster than 60msec.;
#X text 459 206 BUG: Currently the space bar can not be detected.;
#N canvas 511 55 450 300 version-2019-05-01 0;
#X text 16 97 Bug/TODO: The symbol for the space bar has different
captitals 'space' and 'Space' for down and ups.;
#X text 18 31 Expanded from an idea posted by Katja Vetter on the pd
mailing list on March 8th 2019;
#X restore 710 529 pd version-2019-05-01;
#X text 419 530 (c) 2019 Peter P. under the BSD license.;
#X text 458 240 NOTE: Most computer keyboards can not detect more than
3-5 keys depressed together.;
#X connect 3 0 7 0;
#X connect 4 0 3 0;
#X connect 4 1 3 1;
#X connect 5 0 6 0;
#X connect 6 0 4 0;
#X connect 7 1 8 0;
#X connect 8 0 9 0;
#X connect 11 0 1 0;
#X connect 11 0 2 0;
-------------- next part --------------
#N canvas 847 82 516 684 12;
#X obj 107 133 keyname;
#X obj 107 167 t b f;
#X obj 107 234 pack s f;
#X obj 107 204 symbol;
#X obj 107 273 route list;
#X msg 211 398 0;
#X obj 211 475 pipe \$1;
#X obj 107 406 t b b;
#X msg 139 439 clear;
#X obj 107 514 change;
#X obj 107 545 outlet;
#X msg 107 477 1;
#X obj 107 350 sel 1 0;
#X obj 107 309 route \$2;
#N canvas 511 55 450 300 version-2019-05-01 0;
#X text 16 97 Bug/TODO: The symbol for the space bar has different
captitals 'space' and 'Space' for down and ups.;
#X text 18 31 Expanded from an idea posted by Katja Vetter on the pd
mailing list on March 8th 2019;
#X restore 331 647 pd version-2019-05-01;
#X text 40 648 (c) 2019 Peter P. under the BSD license.;
#X connect 0 0 1 0;
#X connect 0 1 3 1;
#X connect 1 0 3 0;
#X connect 1 1 2 1;
#X connect 2 0 4 0;
#X connect 3 0 2 0;
#X connect 4 0 13 0;
#X connect 5 0 6 0;
#X connect 6 0 9 0;
#X connect 7 0 11 0;
#X connect 7 1 8 0;
#X connect 8 0 6 0;
#X connect 9 0 10 0;
#X connect 11 0 9 0;
#X connect 12 0 7 0;
#X connect 12 1 5 0;
#X connect 13 0 12 0;


More information about the Pd-list mailing list