Family Day update

This commit is contained in:
Ingy döt Net 2020-02-17 23:21:07 -08:00
parent aac6731f2c
commit 9ad63ea473
2442 changed files with 39761 additions and 8255 deletions

View file

@ -0,0 +1,19 @@
# syntax: TAWK -f KEYBOARD_INPUT_KEYPRESS_CHECK.AWK
BEGIN {
arr["\b"] = "BACKSPACE"
arr["\t"] = "TAB"
arr["\x0D"] = "ENTER"
printf("%s Press any key; ESC to exit\n",ctime())
while (1) {
nkeys++
key = getkey()
if (key in arr) { key = arr[key] }
space = ((length(key) > 1 && nkeys > 1) || length(p_key) > 1) ? " " : ""
keys = keys space key
if (key == "ESC") { break }
p_key = key
}
printf("%s %d keys were pressed\n",ctime(),nkeys)
printf("%s\n",keys)
exit(0)
}

View file

@ -21,21 +21,3 @@ func main() {
s.Refresh()
time.Sleep(500 * time.Millisecond)
}
s.Println()
gc.Echo(false)
// task requirement next two lines
s.Timeout(0)
k := s.GetChar()
if k == 0 {
s.Println("No key pressed")
} else {
s.Println("You pressed", gc.KeyString(k))
}
s.Refresh()
s.Timeout(-1)
gc.FlushInput()
gc.Cursor(1)
s.GetChar()
}

View file

@ -0,0 +1,31 @@
package main
// stackoverflow.com/questions/43965556/how-to-read-a-key-in-go-but-continue-application-if-no-key-pressed-within-x-seco
import (
"bufio"
"os"
"log"
"fmt"
"time"
)
var reader = bufio.NewReader(os.Stdin)
func readKey(input chan rune) {
char, _, err := reader.ReadRune()
if err != nil {
log.Fatal(err)
}
input <- char
}
func main() {
input := make(chan rune, 1)
fmt.Println("Checking keyboard input...")
go readKey(input)
select {
case i := <-input:
fmt.Printf("Input : %v\n", i)
case <-time.After(5000 * time.Millisecond):
fmt.Println("Time out!")
}
}

View file

@ -0,0 +1,8 @@
: "loop"
if "KEY_PRESSED" != 0 then "#store"
* "Last key pressed: &storedKey&"
goto "loop"
: "#store"
set "storedKey" to "KEY_PRESSED"
goto "#return"