35 lines
770 B
Dart
35 lines
770 B
Dart
import 'dart:io';
|
|
import 'package:libac_dart/utils/IOTools.dart';
|
|
|
|
String getKeyPress() {
|
|
// Disable line mode to capture a single key press without requiring Enter
|
|
stdin.echoMode = false;
|
|
stdin.lineMode = false;
|
|
|
|
// Read a single byte from stdin
|
|
int byte = stdin.readByteSync();
|
|
|
|
// Restore line mode and echo mode to default settings
|
|
stdin.echoMode = true;
|
|
stdin.lineMode = true;
|
|
|
|
// Return the character representation of the byte
|
|
return String.fromCharCode(byte);
|
|
}
|
|
|
|
int main() {
|
|
prnt("\rPress Any Key To Continue...");
|
|
|
|
// Listen for a key press
|
|
String key = getKeyPress();
|
|
|
|
// Erase the line by printing a new line
|
|
prnt("\r\n");
|
|
|
|
// Check if the pressed key is 'Z'
|
|
if (key.toUpperCase() == 'Z') {
|
|
return 1;
|
|
}
|
|
|
|
return 0;
|
|
}
|