How to simulate Window's "Press any key to continue..."
IGotD-
nise at nise.com
Fri Nov 22 11:56:39 UTC 2019
On Friday, 22 November 2019 at 04:45:21 UTC, Mike Parker wrote:
> On Friday, 22 November 2019 at 04:22:07 UTC,
> FireController#1847 wrote:
>
>> Right, but readln will only wait until the user presses the
>> delimiter (by default Enter/Return). I want it to wait until
>> ANY key is pressed, not a specific key
>
> The documentation for std.stdio.File shows two functions for
> reading input: readln and readf. If readln isn't what you want,
> then readf probably is:
>
> https://dlang.org/phobos/std_stdio.html#.File.readf
>
> Also, there's a freely available book online to help get you up
> to speed: Programming in D. Here's the section on reading from
> stdin with readf:
>
> http://ddili.org/ders/d.en/input.html
stdin is buffered and will not be forwarded to the D-library
until you press enter. The solution is different on Linux and
Windows. On Linux you need to disable the "CANON" mode in the
terminal.
https://stackoverflow.com/questions/1449324/how-to-simulate-press-any-key-to-continue
There are a few suggestions for Windows in the link as well.
Annoyingly complicated for such a simple thing but that's how it
is.
More information about the Digitalmars-d-learn
mailing list