write "Click on the piano and type ASDF"
k = new Piano
played = {}
keydown (e) ->
note = noteFromKeyEvent e
if note and not played[note]
played[note] = true
k.tone(note)
do shownotes
keyup (e) ->
note = noteFromKeyEvent e
if note
delete played[note]
k.tone(note, 0)
do shownotes
noteFromKeyEvent = (e) ->
ch = String.fromCharCode(e.which)
return switch ch
when 'A' then 'C'
when 'S' then 'D'
when 'D' then 'E'
when 'F' then 'F'
when 'G' then 'G'
when 'H' then 'A'
when 'J' then 'B'
when 'K' then 'c'
when 'L' then 'd'
when 'W' then '^C'
when 'E' then '^D'
when 'T' then '^F'
when 'Y' then '^G'
when 'U' then '^A'
when 'O' then '^c'
when 'P' then '^d'
else null
write 'Notes: []'
shownotes = ->
$('#notes').text _.keys(played).join('')