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

Sorry, I just noticed the book doesn't cover how to do what you want and it's probably not obvious. You need to call readf with a character format string (%c):

import std.stdio;
void main()
{
    writeln("Press any key to continue...");

    char c;
    readf("%c", &c);
    writeln("Thanks!");
}

Reply via email to