From 6e916169d6b1c670914a421127d5c8b7a7e5ce3d Mon Sep 17 00:00:00 2001 From: Noah Petherbridge Date: Sun, 3 Jan 2021 15:26:03 -0800 Subject: [PATCH] Spacebar event --- event/event.go | 1 + sdl/events.go | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/event/event.go b/event/event.go index 1787e4c..1ed072b 100644 --- a/event/event.go +++ b/event/event.go @@ -11,6 +11,7 @@ type State struct { // Special keys Escape bool + Space bool Enter bool Shift bool Ctrl bool diff --git a/sdl/events.go b/sdl/events.go index 420b77a..2e71067 100644 --- a/sdl/events.go +++ b/sdl/events.go @@ -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) } } }