[racket] on-key question

From: Matthias Felleisen (matthias at ccs.neu.edu)
Date: Wed Mar 14 10:24:39 EDT 2012

On Mar 14, 2012, at 3:53 AM, Roelof Wobben wrote:

> Hello, 
> I have to make a function which do nothing with the special key's.
> According to the manual I can use this : 
> Here is a typical key-event handler:
> (define (change w a-key)
> (cond
> [(key=? a-key "left") (world-go w -DELTA)]
> [(key=? a-key "right") (world-go w +DELTA)]
> [(= (string-length a-key) 1) w] ; order-free checking
> [(key=? a-key "up") (world-go w -DELTA)]
> [(key=? a-key "down") (world-go w +DELTA)]
> [else w]))
> But Can I use this if I want that if a special-key is used nothing happens. 
> [key?a-key "/t") ()]

You need to complete the phrase "nothing happens" and then you will see how you went wrong: 

  "nothing happens to the world". 

You should also look at the signature of this function, which is World -> World i.e. it always
takes a world and returns one (possibly a different one than it got or the same one). 

Posted on the users mailing list.