Re: [racket-dev] multiple key-press

2010-07-30 Thread Matthias Felleisen

I have finally taken the time to design a controller for an object that 
allows the use of multiple arrow keys. Two insights: it is doable and it 
is a truly insightful exercise on state machines. Most of the 'bullet' 
points at the top of the program came about because I designed and explored. 
BUT, the program is quite complex. If you think about it for a moment, 
that's no surprise however. It is working with nine possible states: 
 no arrow pressed, one of four cardinal arrows pressed, two keys 
 pressed simultaneously. 

I think Brown kids should be able to design this kind of function 
w/o a problem. For non-Brown kids, I suspect we would have to wait 
until they have a solid handle of a lot of design ideas. 

QUESTION: should I incorporate this into the docs? Into HtDP/2e (part 1
is already extremely long). 

-- Matthias



(require 2htdp/universe)
(require 2htdp/image)

;; -
;; PROGRAM PURPOSE: move a red circle while one or two arrow keys are pressed 
;; -

;; move only when one or two arrow keys are pressed 
;; when a third arrow key is pressed, ignore it 
;; when a single arrow key is pressed and a contradictory arrow is pressed, 
;;   ignore it too 
;; This program is a nine-state state machine with respect to the direction
;; in which the object is moving. 

;; Boolean - World 
(define (move-by-arrows debug?)
  (big-bang WORLD0
(on-key key-handler)
(on-release release-handler)
(on-tick move)
(to-draw render) 
(state debug?)))

;; -
;; Data Definitions  Constant Definitions 

;; Cardinal is one of: 
;; -- left
;; -- right
;; -- up 
;; -- down
;; interpretation: the four cardinal directions as strings and keyevents 

(define-struct world (dir posn))
;; World is: (world Direction Posn)
;; the current direction and the current position of the circle 

;; Direction is one of:  (Yes, I mean these 10 definitions)
(define BLANK (make-posn 0 0))
(define LEFT (make-posn -1 0))
(define RIGHT (make-posn +1 0))
(define UP (make-posn 0 -1))
(define DOWN (make-posn 0 +1))
(define DOWNLEFT (make-posn -1 +1))
(define DOWNRIGHT (make-posn +1 +1))
(define UPLEFT (make-posn -1 -1))
(define UPRIGHT (make-posn +1 -1))
;; the direction as determined by a sequence of 0, 1, or 2 keys held down 

;; physical constants 
(define SIZE 300)
(define MID  (/ SIZE 2))
(define WORLD0 (make-world BLANK (make-posn MID MID)))

;; graphical constants 
(define DOT  (circle 3 solid red))
(define MT   (empty-scene SIZE SIZE))

;; -
;; World KeyEvent - World
; combine current direction and KeyEvent to create new direction 

(check-expect (key-handler (make-world UP (make-posn 0 0)) left)
  (make-world UPLEFT (make-posn 0 0)))
(check-expect (key-handler (make-world DOWNRIGHT (make-posn 0 0)) left) 
  (make-world DOWNRIGHT (make-posn 0 0)))

(check-expect (key-handler (make-world UP (make-posn 0 0)) down)
  (make-world UP (make-posn 0 0)))
(check-expect (key-handler (make-world DOWNRIGHT (make-posn 0 0)) down) 
  (make-world DOWNRIGHT (make-posn 0 0)))

(define (key-handler ws key)
  (if (cardinal? key)
  (make-world (key-proper (world-dir ws) key) (world-posn ws))
  ws))

;; KeyEvent - Boolean 
(define (cardinal? key)
  (cond
[(string=? left key) true]
[(string=? right key) true]
[(string=? up  key) true]
[(string=? down key) true]
[else false]))

;; Direction Cardinal - Direction 

(check-expect (key-proper UP left) UPLEFT)
(check-expect (key-proper DOWNRIGHT left) DOWNRIGHT)
(check-expect (key-proper RIGHT up) UPRIGHT)

;; Direction Cardinal - Direction 
(define (key-proper ws key)
  (cond
[(equal? BLANK ws) 
 (cond
   [(string=? left key) LEFT]
   [(string=? right key) RIGHT] ;; arbitrary decision 
   [(string=? up  key) UP] 
   [(string=? down key) DOWN])]
[(equal? LEFT ws) 
 (cond
   [(string=? left key) ws]
   [(string=? right key) ws] ;; arbitrary decision 
   [(string=? up  key) UPLEFT] ;; (string-append key ws) wouldn't be 
typable 
   [(string=? down key) DOWNLEFT])]
[(equal? RIGHT ws) 
 (cond
   [(string=? left key) ws] ;; arbitrary decision 
   [(string=? right key) ws] 
   [(string=? up  key) UPRIGHT] 
   [(string=? down key) DOWNRIGHT])]
[(equal? UP  ws) 
 (cond
   [(string=? left key) UPLEFT]
   [(string=? right key) UPRIGHT] 
   [(string=? up  key) ws]
   [(string=? down key) ws])]  ;; arbitrary decision 
[(equal? DOWN ws) 
 (cond
   [(string=? left key) DOWNLEFT]
   [(string=? right key) DOWNRIGHT] 
   [(string=? up  key) ws]
   [(string=? down key) ws])]
[(equal? 

Re: [racket-dev] multiple key-press

2010-07-30 Thread Robby Findler
Looks like it would make a nice, involved exercise if you told the
students what the right world type should be.

Did you consider making the world be a list of keys and a posn
(inserting and removing from the list in the key handler and
interpreting the list of keys in the tick handler)?

Robby

On Friday, July 30, 2010, Matthias Felleisen matth...@ccs.neu.edu wrote:

 I have finally taken the time to design a controller for an object that
 allows the use of multiple arrow keys. Two insights: it is doable and it
 is a truly insightful exercise on state machines. Most of the 'bullet'
 points at the top of the program came about because I designed and explored.
 BUT, the program is quite complex. If you think about it for a moment,
 that's no surprise however. It is working with nine possible states:
  no arrow pressed, one of four cardinal arrows pressed, two keys
  pressed simultaneously.

 I think Brown kids should be able to design this kind of function
 w/o a problem. For non-Brown kids, I suspect we would have to wait
 until they have a solid handle of a lot of design ideas.

 QUESTION: should I incorporate this into the docs? Into HtDP/2e (part 1
 is already extremely long).

 -- Matthias



 (require 2htdp/universe)
 (require 2htdp/image)

 ;; 
 -
 ;; PROGRAM PURPOSE: move a red circle while one or two arrow keys are pressed
 ;; 
 -

 ;; move only when one or two arrow keys are pressed
 ;; when a third arrow key is pressed, ignore it
 ;; when a single arrow key is pressed and a contradictory arrow is pressed,
 ;;   ignore it too
 ;; This program is a nine-state state machine with respect to the direction
 ;; in which the object is moving.

 ;; Boolean - World
 (define (move-by-arrows debug?)
   (big-bang WORLD0
             (on-key key-handler)
             (on-release release-handler)
             (on-tick move)
             (to-draw render)
             (state debug?)))

 ;; 
 -
 ;; Data Definitions  Constant Definitions

 ;; Cardinal is one of:
 ;; -- left
 ;; -- right
 ;; -- up
 ;; -- down
 ;; interpretation: the four cardinal directions as strings and keyevents

 (define-struct world (dir posn))
 ;; World is: (world Direction Posn)
 ;; the current direction and the current position of the circle

 ;; Direction is one of:  (Yes, I mean these 10 definitions)
 (define BLANK (make-posn 0 0))
 (define LEFT (make-posn -1 0))
 (define RIGHT (make-posn +1 0))
 (define UP (make-posn 0 -1))
 (define DOWN (make-posn 0 +1))
 (define DOWNLEFT (make-posn -1 +1))
 (define DOWNRIGHT (make-posn +1 +1))
 (define UPLEFT (make-posn -1 -1))
 (define UPRIGHT (make-posn +1 -1))
 ;; the direction as determined by a sequence of 0, 1, or 2 keys held down

 ;; physical constants
 (define SIZE 300)
 (define MID  (/ SIZE 2))
 (define WORLD0 (make-world BLANK (make-posn MID MID)))

 ;; graphical constants
 (define DOT  (circle 3 solid red))
 (define MT   (empty-scene SIZE SIZE))

 ;; 
 -
 ;; World KeyEvent - World
 ; combine current direction and KeyEvent to create new direction

 (check-expect (key-handler (make-world UP (make-posn 0 0)) left)
               (make-world UPLEFT (make-posn 0 0)))
 (check-expect (key-handler (make-world DOWNRIGHT (make-posn 0 0)) left)
               (make-world DOWNRIGHT (make-posn 0 0)))

 (check-expect (key-handler (make-world UP (make-posn 0 0)) down)
               (make-world UP (make-posn 0 0)))
 (check-expect (key-handler (make-world DOWNRIGHT (make-posn 0 0)) down)
               (make-world DOWNRIGHT (make-posn 0 0)))

 (define (key-handler ws key)
   (if (cardinal? key)
       (make-world (key-proper (world-dir ws) key) (world-posn ws))
       ws))

 ;; KeyEvent - Boolean
 (define (cardinal? key)
   (cond
     [(string=? left key) true]
     [(string=? right key) true]
     [(string=? up  key) true]
     [(string=? down key) true]
     [else false]))

 ;; Direction Cardinal - Direction

 (check-expect (key-proper UP left) UPLEFT)
 (check-expect (key-proper DOWNRIGHT left) DOWNRIGHT)
 (check-expect (key-proper RIGHT up) UPRIGHT)

 ;; Direction Cardinal - Direction
 (define (key-proper ws key)
   (cond
     [(equal? BLANK ws)
      (cond
        [(string=? left key) LEFT]
        [(string=? right key) RIGHT] ;; arbitrary decision
        [(string=? up  key) UP]
        [(string=? down key) DOWN])]
     [(equal? LEFT ws)
      (cond
        [(string=? left key) ws]
        [(string=? right key) ws] ;; arbitrary decision
        [(string=? up  key) UPLEFT] ;; (string-append key ws) wouldn't be 
 typable
        [(string=? down key) DOWNLEFT])]
     [(equal? RIGHT ws)
      (cond
        [(string=? left key) ws] ;; arbitrary decision
        [(string=? right key) ws]
        [(string=? 

Re: [racket-dev] multiple key-press

2010-07-30 Thread Matthias Felleisen


On Jul 30, 2010, at 4:25 PM, Robby Findler wrote:

 Looks like it would make a nice, involved exercise if you told the
 students what the right world type should be.


It would reinforce the FSA design idea, but it will consume space. 
I'll put it on my list and see how much space I need. 


 Did you consider making the world be a list of keys and a posn
 (inserting and removing from the list in the key handler and
 interpreting the list of keys in the tick handler)?


Yes, Paul had posted such a solution. I wanted to see what 
solution for part 1 would look like (no lists). 




 
 Robby
 
 On Friday, July 30, 2010, Matthias Felleisen matth...@ccs.neu.edu wrote:
 
 I have finally taken the time to design a controller for an object that
 allows the use of multiple arrow keys. Two insights: it is doable and it
 is a truly insightful exercise on state machines. Most of the 'bullet'
 points at the top of the program came about because I designed and explored.
 BUT, the program is quite complex. If you think about it for a moment,
 that's no surprise however. It is working with nine possible states:
  no arrow pressed, one of four cardinal arrows pressed, two keys
  pressed simultaneously.
 
 I think Brown kids should be able to design this kind of function
 w/o a problem. For non-Brown kids, I suspect we would have to wait
 until they have a solid handle of a lot of design ideas.
 
 QUESTION: should I incorporate this into the docs? Into HtDP/2e (part 1
 is already extremely long).
 
 -- Matthias
 
 
 
 (require 2htdp/universe)
 (require 2htdp/image)
 
 ;; 
 -
 ;; PROGRAM PURPOSE: move a red circle while one or two arrow keys are pressed
 ;; 
 -
 
 ;; move only when one or two arrow keys are pressed
 ;; when a third arrow key is pressed, ignore it
 ;; when a single arrow key is pressed and a contradictory arrow is pressed,
 ;;   ignore it too
 ;; This program is a nine-state state machine with respect to the direction
 ;; in which the object is moving.
 
 ;; Boolean - World
 (define (move-by-arrows debug?)
  (big-bang WORLD0
(on-key key-handler)
(on-release release-handler)
(on-tick move)
(to-draw render)
(state debug?)))
 
 ;; 
 -
 ;; Data Definitions  Constant Definitions
 
 ;; Cardinal is one of:
 ;; -- left
 ;; -- right
 ;; -- up
 ;; -- down
 ;; interpretation: the four cardinal directions as strings and keyevents
 
 (define-struct world (dir posn))
 ;; World is: (world Direction Posn)
 ;; the current direction and the current position of the circle
 
 ;; Direction is one of:  (Yes, I mean these 10 definitions)
 (define BLANK (make-posn 0 0))
 (define LEFT (make-posn -1 0))
 (define RIGHT (make-posn +1 0))
 (define UP (make-posn 0 -1))
 (define DOWN (make-posn 0 +1))
 (define DOWNLEFT (make-posn -1 +1))
 (define DOWNRIGHT (make-posn +1 +1))
 (define UPLEFT (make-posn -1 -1))
 (define UPRIGHT (make-posn +1 -1))
 ;; the direction as determined by a sequence of 0, 1, or 2 keys held down
 
 ;; physical constants
 (define SIZE 300)
 (define MID  (/ SIZE 2))
 (define WORLD0 (make-world BLANK (make-posn MID MID)))
 
 ;; graphical constants
 (define DOT  (circle 3 solid red))
 (define MT   (empty-scene SIZE SIZE))
 
 ;; 
 -
 ;; World KeyEvent - World
 ; combine current direction and KeyEvent to create new direction
 
 (check-expect (key-handler (make-world UP (make-posn 0 0)) left)
  (make-world UPLEFT (make-posn 0 0)))
 (check-expect (key-handler (make-world DOWNRIGHT (make-posn 0 0)) left)
  (make-world DOWNRIGHT (make-posn 0 0)))
 
 (check-expect (key-handler (make-world UP (make-posn 0 0)) down)
  (make-world UP (make-posn 0 0)))
 (check-expect (key-handler (make-world DOWNRIGHT (make-posn 0 0)) down)
  (make-world DOWNRIGHT (make-posn 0 0)))
 
 (define (key-handler ws key)
  (if (cardinal? key)
  (make-world (key-proper (world-dir ws) key) (world-posn ws))
  ws))
 
 ;; KeyEvent - Boolean
 (define (cardinal? key)
  (cond
[(string=? left key) true]
[(string=? right key) true]
[(string=? up  key) true]
[(string=? down key) true]
[else false]))
 
 ;; Direction Cardinal - Direction
 
 (check-expect (key-proper UP left) UPLEFT)
 (check-expect (key-proper DOWNRIGHT left) DOWNRIGHT)
 (check-expect (key-proper RIGHT up) UPRIGHT)
 
 ;; Direction Cardinal - Direction
 (define (key-proper ws key)
  (cond
[(equal? BLANK ws)
 (cond
   [(string=? left key) LEFT]
   [(string=? right key) RIGHT] ;; arbitrary decision
   [(string=? up  key) UP]
   [(string=? down key) DOWN])]
[(equal? LEFT ws)
 (cond
   [(string=? left key) ws]
   [(string=? right key) 

Re: [racket-dev] multiple key-press

2010-07-23 Thread Matthias Felleisen

Thanks for all the ideas. Just to clarify: this spring I modified the API of 
Universe to accommodate this form of 'multiple' keypresses. I have to work out 
examples and probably add one more handler to get this 'right' (for beginners). 
(The person who posted isn't really a beginner in the sense of novice but a kid 
who mastered a good amount of Java and was set loose on the beginning 
languages. Perhaps he should have been thrown at full Racket from the 
beginning.) 
_
  For list-related administrative tasks:
  http://lists.racket-lang.org/listinfo/dev


Re: [racket-dev] multiple key-press

2010-07-23 Thread Paul Ojanen
Here's an example to see what is detectable.  ALT and SHIFT are
interesting...try with lowercase first.

#lang racket
(require 2htdp/universe)
{require 2htdp/image}

;;;
;; Demonstrates how to detect multiple key presses   ;;
;;  - Only up to six or so keys are individually detectable  ;;
;;-- my laptop does asdfjk   ;;
;;  - In some combinations, fewer individual keys are detectable ;;
;;-- my laptop does not do qzc   ;;
;;  - I think these limitations have to do with the hardware,;;
;;so some keyboards may do better or worse   ;;
;;;

; NOTE:  The ALT and SHIFT keys can break things in the current API
; Playing with them will generate some off but understandable behavior


; WorldState is a list of strings, indicating which keys are being held down
(define INIT_WORLD empty)

; key-handler: WorldState String - WorldState
; purpose: Add key to the world without duplication
(define (key-handler ws key)
  (if (not (member key ws))
  (cons key ws)
  ws))

; release-handler: WorldState String - WorldState
; purpose: Remove all instances of key from the world
(define (release-handler ws key)
  (if (member key ws)
  (release-handler (remove key ws) key)
  ws))

; render: WorldState - Scene
; purpose: Provide a blank canvas in order to receive key events
(define (render ws)
  (rectangle 300 300 solid white))

(big-bang INIT_WORLD (on-key key-handler) (on-release release-handler)
(state true) (on-draw render))



 -Original Message-
 From: dev-boun...@racket-lang.org [mailto:dev-boun...@racket-lang.org] On
 Behalf Of Matthias Felleisen
 Sent: Friday, July 23, 2010 10:14 AM
 To: PLT Developers
 Subject: Re: [racket-dev] multiple key-press
 
 
 Thanks for all the ideas. Just to clarify: this spring I modified the API
 of Universe to accommodate this form of 'multiple' keypresses. I have to
 work out examples and probably add one more handler to get this 'right'
 (for beginners). (The person who posted isn't really a beginner in the
 sense of novice but a kid who mastered a good amount of Java and was set
 loose on the beginning languages. Perhaps he should have been thrown at
 full Racket from the beginning.)
 _
   For list-related administrative tasks:
   http://lists.racket-lang.org/listinfo/dev

_
  For list-related administrative tasks:
  http://lists.racket-lang.org/listinfo/dev


[racket-dev] multiple key-press

2010-07-22 Thread Shriram Krishnamurthi
I just spoke with a room of high-school students studying Universe
programming in a summer course at Brown.

One major complaint was that they couldn't do multi-key-presses.  For
instance, they want to use WASD navigation combined with a right-side
key for firing, and want to be able to fire and navigate at the same
time.

They've been using Shift, but the general consensus amongst the kids
was this was Not Cool.  Basically, they felt like they were being
cheated out of building a real game.

I don't know what it would take to support this.

Shriram
_
  For list-related administrative tasks:
  http://lists.racket-lang.org/listinfo/dev


Re: [racket-dev] multiple key-press

2010-07-22 Thread Jay McCarthy
As far as I know, at the lowest level there is no multiple key press
event even in the OS.

If they want to do that, they should change their world to record the
current key press state:

(define-struct the-world (keys . everything-else))

and at the start of `on-tick' look at the collective impact of all the
keys, resetting it to 'empty' when the new world is returned.

That's more like how actually game engines work anyways.

Jay

On Thu, Jul 22, 2010 at 7:25 AM, Shriram Krishnamurthi s...@cs.brown.edu 
wrote:
 I just spoke with a room of high-school students studying Universe
 programming in a summer course at Brown.

 One major complaint was that they couldn't do multi-key-presses.  For
 instance, they want to use WASD navigation combined with a right-side
 key for firing, and want to be able to fire and navigate at the same
 time.

 They've been using Shift, but the general consensus amongst the kids
 was this was Not Cool.  Basically, they felt like they were being
 cheated out of building a real game.

 I don't know what it would take to support this.

 Shriram
 _
  For list-related administrative tasks:
  http://lists.racket-lang.org/listinfo/dev




-- 
Jay McCarthy j...@cs.byu.edu
Assistant Professor / Brigham Young University
http://teammccarthy.org/jay

The glory of God is Intelligence - DC 93
_
  For list-related administrative tasks:
  http://lists.racket-lang.org/listinfo/dev

Re: [racket-dev] multiple key-press

2010-07-22 Thread Matthias Felleisen

I have considered this issue. I decided that these kinds of kids should be 
introduced to Universe programs as opposed to World programs. That's way cooler 
than silly one-keyboard games. 



-- Matthias





On Jul 22, 2010, at 9:29 AM, Jay McCarthy wrote:

 As far as I know, at the lowest level there is no multiple key press
 event even in the OS.
 
 If they want to do that, they should change their world to record the
 current key press state:
 
 (define-struct the-world (keys . everything-else))
 
 and at the start of `on-tick' look at the collective impact of all the
 keys, resetting it to 'empty' when the new world is returned.
 
 That's more like how actually game engines work anyways.
 
 Jay
 
 On Thu, Jul 22, 2010 at 7:25 AM, Shriram Krishnamurthi s...@cs.brown.edu 
 wrote:
 I just spoke with a room of high-school students studying Universe
 programming in a summer course at Brown.
 
 One major complaint was that they couldn't do multi-key-presses.  For
 instance, they want to use WASD navigation combined with a right-side
 key for firing, and want to be able to fire and navigate at the same
 time.
 
 They've been using Shift, but the general consensus amongst the kids
 was this was Not Cool.  Basically, they felt like they were being
 cheated out of building a real game.
 
 I don't know what it would take to support this.
 
 Shriram
 _
  For list-related administrative tasks:
  http://lists.racket-lang.org/listinfo/dev
 
 
 
 
 -- 
 Jay McCarthy j...@cs.byu.edu
 Assistant Professor / Brigham Young University
 http://teammccarthy.org/jay
 
 The glory of God is Intelligence - DC 93
 _
  For list-related administrative tasks:
  http://lists.racket-lang.org/listinfo/dev

_
  For list-related administrative tasks:
  http://lists.racket-lang.org/listinfo/dev


Re: [racket-dev] multiple key-press

2010-07-22 Thread Shriram Krishnamurthi
 As far as I know, at the lowest level there is no multiple key press
 event even in the OS.

Yes, that's why I had scare-quotes in my message.

 If they want to do that, they should change their world to record the
 current key press state:

I told them that.  But the problem is that inversion of control makes
the world structure and its logic *significantly* uglier.

 I have considered this issue. I decided that these kinds of kids
 should be introduced to Universe programs as opposed to World
 programs. That's way cooler than silly one-keyboard games.

Doom is silly?  Duke Nukem 3D is silly?

Perhaps you do indeed know a great deal about games.  But perhaps you
have a more limited understanding of your audience.

Shriram
_
  For list-related administrative tasks:
  http://lists.racket-lang.org/listinfo/dev


Re: [racket-dev] multiple key-press

2010-07-22 Thread Matthias Felleisen

On Jul 22, 2010, at 9:38 AM, Shriram Krishnamurthi wrote:

 
 I have considered this issue. I decided that these kinds of kids
 should be introduced to Universe programs as opposed to World
 programs. That's way cooler than silly one-keyboard games.
 
 Doom is silly?  Duke Nukem 3D is silly?
 
 Perhaps you do indeed know a great deal about games.  But perhaps you
 have a more limited understanding of your audience.

This issue came up at NEU at some point, and when we showed the kids Universe 
in response, they though it was way cooler to run the multi-player game on many 
computers than on a single keyboard. (I don't know whether they implemented 
it.) 
_
  For list-related administrative tasks:
  http://lists.racket-lang.org/listinfo/dev


Re: [racket-dev] multiple key-press

2010-07-22 Thread Jay McCarthy
On Thu, Jul 22, 2010 at 7:38 AM, Shriram Krishnamurthi s...@cs.brown.edu 
wrote:
 As far as I know, at the lowest level there is no multiple key press
 event even in the OS.

 Yes, that's why I had scare-quotes in my message.

 If they want to do that, they should change their world to record the
 current key press state:

 I told them that.  But the problem is that inversion of control makes
 the world structure and its logic *significantly* uglier.

We could change world/universe to automatically do this batching of
key presses and have an interaction-rate similar to the tick-rate.
I'm not sure THAT would be much better, but it would be less tedious,
etc.

Jay


 I have considered this issue. I decided that these kinds of kids
 should be introduced to Universe programs as opposed to World
 programs. That's way cooler than silly one-keyboard games.

 Doom is silly?  Duke Nukem 3D is silly?

 Perhaps you do indeed know a great deal about games.  But perhaps you
 have a more limited understanding of your audience.

 Shriram




-- 
Jay McCarthy j...@cs.byu.edu
Assistant Professor / Brigham Young University
http://teammccarthy.org/jay

The glory of God is Intelligence - DC 93
_
  For list-related administrative tasks:
  http://lists.racket-lang.org/listinfo/dev

Re: [racket-dev] multiple key-press

2010-07-22 Thread YC
On Thu, Jul 22, 2010 at 6:43 AM, Jay McCarthy jay.mccar...@gmail.comwrote:

 On Thu, Jul 22, 2010 at 7:38 AM, Shriram Krishnamurthi s...@cs.brown.edu
 wrote:
  As far as I know, at the lowest level there is no multiple key press
  event even in the OS.
 


Not that there is a multiple key press event in OS, but below are some
potential solutions/examples in other languages:

Here's a potential solution in C# describing looking up keyboard states via
kernel32.dll - not sure whether it will easily be applicable/ported in your
scenario.

http://stackoverflow.com/questions/2686019/multiple-key-presses-doing-different-events-in-c

Processing also appear to handle multiple keypress (code):

http://wiki.processing.org/index.php?title=Keep_track_of_multiple_key_presses

Here's one demo in flash with WASD - but did not show firing:

http://www.freeactionscript.com/2009/02/multiple-key-press-detection/

Cheers,
yc
_
  For list-related administrative tasks:
  http://lists.racket-lang.org/listinfo/dev