From 32c186e1e2da7dc6623adf4fc1a98c0b376d04d9 Mon Sep 17 00:00:00 2001 From: Bel LaPointe Date: Thu, 23 Mar 2023 15:53:01 -0600 Subject: [PATCH] input ignores newline chars --- src/device/input/keyboard.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/device/input/keyboard.go b/src/device/input/keyboard.go index ea5e2ec..d9babb8 100644 --- a/src/device/input/keyboard.go +++ b/src/device/input/keyboard.go @@ -50,9 +50,11 @@ func (kb Keyboard) Read() []Button { panic(err) } - result := make([]Button, n) - for i := range result { - result[i] = Button{Char: b[i], Down: true} + result := make([]Button, 0, n) + for i := 0; i < n; i++ { + if b[i] != '\n' { + result = append(result, Button{Char: b[i], Down: true}) + } } return result }