Description
Dart SDK Version: Dart VM version: 2.4.0
OS: Windows 10 x64
I am working on a command line dart application and am looking for the ability to detect keyboard events. For example, if the user presses ctrl (or cmd), this would cause different behavior as the program executes tasks. I have found a few instances that seem to get close, but do not have the complete extendability I am looking for. Specifically:
- https://pub.dev/packages/hotkey - this one is simply out of date, but also seems like it is only for html applications, same as current keyboard support (the dart:html library).
- POSIX signal handling (SIGINT, SIGTERM, SIGHUP, etc) #15188 - this is useful for special cases but does not extend beyond signals
I tried a very simple test, but similarly, it does not get very far:
import 'dart:io';
void main() {
stdin.echoMode = false;
stdin.lineMode = false;
stdin.listen((data) {
print (data);
});
}
since it only prints out on pressing down (cannot detect holding a key) and does not recognize when the shift or ctrl key are pressed alone since they do not write alone.
Another thought that I have not tried yet was starting a separate process and try to detect keyboard input through a separate pipe, but this seems clunky and does not solve the root problem of lower-level access to keyboard interaction.
I am wondering if there is planned support for handling more advanced keyboard combinations (non-blocking) with special keys like ctrl and shift for command-line written dart applications. If there is not, whether any community libraries have been written. Lastly, if the answer is no to both questions, possible (preferably simple 😄) implementations. What would be of most importance is regarding holding ctrl or shift. Thanks!