SimpleHelperTools/dart/bin/pause.dart
2024-08-31 01:24:36 -07:00

18 lines
No EOL
551 B
Dart

import 'dart:io';
void main(List<String> arguments) {
stdout.write('Press any key to continue...');
while (true) {
int charCode = stdin.readByteSync(); // Read a single byte
String char = String.fromCharCode(charCode).toLowerCase(); // Convert byte to character and lowercase it
// Check if the input is "Enter" or between 'a' and 'z'
if (charCode == 10 || (char.compareTo('a') >= 0 && char.compareTo('z') <= 0)) {
break; // Exit loop if valid input is received
}
}
print(''); // Print a newline for formatting
}