[Fluxus] Key events
    gabor papp 
    gabor.lists at mndl.hu
       
    Fri Jun  8 10:39:47 PDT 2012
    
    
  
hi Carlos,
> true in the frame where I press the space bar for the first time, but also
> at some other frames after the first one, when the space bar is pressed
yes, as Kassen already mentioned this is normal and comes from the 
keyboard repeat.
> I took a look into modules/scheme/input.ss to try to implement this behavior
> as you said, but as I am new to fluxus I would first get familiar with its
sorry for bringing that solution up. it is probably too complex for this 
problem. i thought you need callbacks on key presses.
> source code. Thus, I ended up implementing all using (key-pressed-this-frame
> " "):
clever solution. as i see you are detecting key release.
are you using fluxus from git? maybe we should add a (key-released) 
function which could make this simpler.
something like this would be more general for now:
(define PLAY #f)
(define key-released
     (let ([keys-down-last '()])
         (lambda (key)
             (let* ([keych (string-ref key 0)]
                    [released (and (member keych keys-down-last)
                                   (not (member keych (keys-down))))])
                 (set! keys-down-last (keys-down))
                 released))))
(define (render)
     (when (key-released " ")
         (set! PLAY (not PLAY)))
     (when PLAY
         ...))
(every-frame (render))
best,
gabor
    
    
More information about the Fluxus
mailing list