[racket] puzzled by what (send key-event get-key-code) returns

From: Jay McCarthy (jay.mccarthy at gmail.com)
Date: Tue Feb 25 19:53:54 EST 2014

When you press a key, say A, and then release it, there are two
key-events that are registered. The first has "get-key-code" as #\A.
The second has "get-key-code" 'release and #\A is returned by


On Tue, Feb 25, 2014 at 5:49 PM, Tom Dean <tld at google.com> wrote:
> If I create an instance of  canvas% or editor-canvas% like
> (define THE-CANVAS (new (class editor-canvas%
>                                (super-new)
>                                ;; Key handler for key-stroke input:
>                                (define/override (on-char key-event)
>                                  (let ([event (send key-event
> get-key-code)])
>                                    (printf "EQ? ~s~n" (eq? event #\[)))))))
> and then hit the [  key it's as though the event is a pair consisting of a
> char #\[ and the symbol 'release:
> EQ? #t
> EQ? #f
> bur event isn't a pair?, list? or any other type as far as I can tell. And
> it doesn't appear that get-key-code is returning multiple values, at least
> in the sense of being something I can capture with let-values or set-values.
> Any clues how I might capture just the key code and not the release symbol?
> ____________________
>   Racket Users list:
>   http://lists.racket-lang.org/users

Jay McCarthy <jay at cs.byu.edu>
Assistant Professor / Brigham Young University

"The glory of God is Intelligence" - D&C 93

Posted on the users mailing list.