From 95d2a88a7c1e26247900227ec1a44747ad593d34 Mon Sep 17 00:00:00 2001 From: Brian Buller Date: Sat, 26 Dec 2015 10:46:18 -0600 Subject: [PATCH] Added alpha-numeric input tester --- termbox_util.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/termbox_util.go b/termbox_util.go index db05a84..55d5072 100644 --- a/termbox_util.go +++ b/termbox_util.go @@ -19,6 +19,18 @@ const ( AlignRight ) +/* Basic Input Helpers */ + +// KeyIsAlphaNumeric Returns whether the termbox event is an +// Alpha-Numeric Key Press +func KeyIsAlphaNumeric(event termbox.Event) { + k := event.Ch + if (k >= 'a' && k <= 'z') || (k >= 'A' && k <= 'Z') || (k >= '0' && k <= '9') { + return true + } + return false +} + /* Basic Output Helpers */ // DrawStringAtPoint Draw a string of text at x, y with foreground color fg, background color bg