Non-blocking keyboard input

Adam D Ruppe destructionator at gmail.com
Wed Dec 27 13:27:53 UTC 2023


On Wednesday, 27 December 2023 at 05:07:04 UTC, Joe wrote:
> ??????????????????????????????????????? Surely there there is a 
> one liner library solution  for this?

It is not one line because it needs a bit of setup (and teardown, 
but the objects' destructors do that for you) but it is close:

http://arsd-official.dpldocs.info/arsd.terminal.html#single-key

`input.getch` waits for a single line, but you can use 
`if(input.kbhit())` to see if it would block before calling it.

> This shouldn't be hard... yet it is.

Better be careful, the mods are out in force deleting posts this 
week that tell the hard truth. But yeah, the stdlib in D has very 
little activity:

https://github.com/dlang/phobos/graphs/contributors?

So you can't expect much from it. My arsd libs provide a broad 
set of functionality missing from it: stuff like this 
terminal/console stuff, window creation, basic guis, web servers, 
etc.

If you want to try them, you can use it from the dub system, but 
I recommend just `git clone 
https://github.com/adamdruppe/arsd.git` in your working directory 
then import what you want and use `dmd -i` to automatically 
include them in the build.


More information about the Digitalmars-d-learn mailing list