PencilCode / jquery-turtle

Turtle Graphics for JQuery
Other
44 stars 25 forks source link

Add a "pressed" function to support keyboard polling. #57

Closed davidbau closed 10 years ago

davidbau commented 10 years ago

Usage:

if pressed 'A' then write 'the A key is pressed.' if pressed 'control' then write 'the Control key is pressed.' write 'All pressed keys: ' + pressed.list().join(',')

It handles chording and resets tracked state when focus is lost.

davidbau commented 10 years ago

I'm preparing this change to make it easier to make keyboard-based games.

You can poll the left-arrow-key (for example) by testing

if pressed 'left' then write 'Left is pressed'

ericfs commented 10 years ago

API looks nice. Please let me know if you get this in before class.

davidbau commented 10 years ago

OK, I've updated based on your changes, and i'm merging to master. Thanks for the code review!