Browse Source

Spacebar event

master
Noah Petherbridge 6 months ago
parent
commit
6e916169d6
2 changed files with 4 additions and 1 deletions
  1. +1
    -0
      event/event.go
  2. +3
    -1
      sdl/events.go

+ 1
- 0
event/event.go View File

@@ -11,6 +11,7 @@ type State struct {

// Special keys
Escape bool
Space bool
Enter bool
Shift bool
Ctrl bool


+ 3
- 1
sdl/events.go View File

@@ -166,12 +166,14 @@ func (r *Renderer) Poll() (*event.State, error) {
s.Ctrl = t.State == 1
case sdl.SCANCODE_RCTRL:
s.Ctrl = t.State == 1
case sdl.SCANCODE_SPACE:
s.Space = t.State == 1
case sdl.SCANCODE_BACKSPACE:
// Make it a key event with "\b" as the sequence.
s.SetKeyDown(`\b`, t.State == 1 || t.Repeat == 1)
default:
// Push the string value of the key.
s.SetKeyDown(string(t.Keysym.Sym), t.State == 1)
s.SetKeyDown(string(t.Keysym.Sym), t.State == 1 || t.Repeat == 1)
}
}
}


Loading…
Cancel
Save