Read from terminal when enter is pressed, but do other stuff in the mean time...

NotSpooky via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Jul 13 09:38:10 PDT 2017


On Thursday, 13 July 2017 at 15:52:57 UTC, Dustmight wrote:
> How do I read in input from the terminal without sitting there 
> waiting for it? I've got code I want to run while there's no 
> input, and then code I want to act on input when it comes in. 
> How do I do both these things?

Might want to check Adam's Terminal.d
https://code.dlang.org/packages/arsd-official%3Aterminal
Docs at http://dpldocs.info/experimental-docs/arsd.terminal.html

You can use a RealTimeConsoleInput with getch. You can use kbhit 
to check whether getch would block. However I found inconsistent 
behavior between platforms with kbhit, so might wanna test.


More information about the Digitalmars-d-learn mailing list