is there a way to pause a program and resume with just a key press (or enter key)

Adam D. Ruppe via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Jul 15 14:15:36 PDT 2014


On Tuesday, 15 July 2014 at 02:49:56 UTC, WhatMeWorry wrote:
> Is there a way to continue with any old key press? or just the 
> enter key?

Yeah. It is more complex than you'd think but my terminal library 
can do it:

https://github.com/adamdruppe/arsd/blob/master/terminal.d

Example usage:

import terminal;

void main() {
   auto terminal = Terminal(ConsoleOutputType.linear);

   // gives real time input capability
   auto input = RealTimeConsoleInput(&terminal, 
ConsoleInputFlags.raw);

   // write to them
   terminal.writeln("Press any key to exit");

   // get a single key
   auto ch = input.getch();
   terminal.writeln("Bye!");
}


PS this is also described in my book 
http://www.packtpub.com/discover-advantages-of-programming-in-d-cookbook/book


More information about the Digitalmars-d-learn mailing list