Daniel, I'd like to see source code for this if you're able. Thanks, Mike
On Saturday, April 16, 2022 at 6:21:30 AM UTC-4 Daniel Jankins wrote: > Thank you, > That is what I did. It works very well. > Thank you again > > On Fri, Apr 15, 2022 at 8:48 PM Kurtis Rader <kra...@skepticism.us> wrote: > >> On Fri, Apr 15, 2022 at 6:35 AM Daniel Jankins <djan...@gmail.com> wrote: >> >>> I have a newbie question. I want to loop until a char is available >>> (keypress). >>> Could someone point me to an example. >>> >> >> I can't point you to an example because that wouldn't be idiomatic Go; >> thus such examples are (I hope) hard to find. In Go you shouldn't busy wait >> using a function like "kbhit >> <https://www.geeksforgeeks.org/kbhit-c-language/>" . You should create a >> channel for communicating the keys that are seen, create a goroutine that >> reads from os.Stdin and injects keys into that channel, then use an event >> loop in a different goroutine that uses "select >> <https://go.dev/ref/spec#Select_statements>" to read key events from >> that channel. >> >> -- >> Kurtis Rader >> Caretaker of the exceptional canines Junior and Hank >> > > > -- > DanJ > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/549d92b7-009f-4db6-8677-f59050fbdb18n%40googlegroups.com.