Better piano keybinds

This commit is contained in:
Sasha Koshka 2023-02-09 16:36:38 -05:00
parent 5446ffe40b
commit e3aea7fc9e
2 changed files with 45 additions and 18 deletions

View File

@ -127,24 +127,50 @@ func (element *Piano) pressUnderMouseCursor (point image.Point) {
}
var noteForKey = map[input.Key] music.Note {
'a': 60,
'w': 61,
's': 62,
'e': 63,
'd': 64,
'f': 65,
't': 66,
'g': 67,
'y': 68,
'h': 69,
'u': 70,
'j': 71,
'k': 72,
'o': 73,
'l': 74,
'p': 75,
';': 76,
'\'': 77,
'a': 46,
'z': 47,
'x': 48,
'd': 49,
'c': 50,
'f': 51,
'v': 52,
'b': 53,
'h': 54,
'n': 55,
'j': 56,
'm': 57,
'k': 58,
',': 59,
'.': 60,
';': 61,
'/': 62,
'\'': 63,
'1': 56,
'q': 57,
'2': 58,
'w': 59,
'e': 60,
'4': 61,
'r': 62,
'5': 63,
't': 64,
'y': 65,
'7': 66,
'u': 67,
'8': 68,
'i': 69,
'9': 70,
'o': 71,
'p': 72,
'-': 73,
'[': 74,
'=': 75,
']': 76,
'\\': 77,
}
func (element *Piano) HandleKeyDown (key input.Key, modifiers input.Modifiers) {

View File

@ -49,6 +49,7 @@ func run () {
container.Adopt(piano, true)
piano.OnPress(playNote)
piano.OnRelease(stopNote)
piano.Focus()
window.OnClose(tomo.Stop)
window.Show()