Suggestion - Convey the status of key modifiers at the time a program is started.
- Dominant language
- PowerShell
- Stars
- 22k
- Forks
- 4.9k
- Avg merge
- 5d 5h
- Merged PRs (30d)
- 29
Description
# Convey the status of key modifiers in effect, at the time a program is started.
# Problem Statement
When a console application is started by a user using a keyboard and a terminal/console shell, the system allows the application to obtain the command line arguments that may be present.
It does not however allow the application to determine if `Shift, Ctrl or Alt `were being pressed at the same time as the `Enter `key used to start the application.
By making this available, it would give application developers a way to convey additional information to the app, additional to that supplied as command line arguments.
The Console static class however, does provide this when an app uses it to prompt for or read user input, this is present as the `Modifiers `member of the `ConsoleKeyInfo `struct.
For example an app could be invoked with `Enter `and it will start executing until it completes, but if a user could press `Shift-Enter` and the started app was able to detect that fact, it could enter into an interactive mode where a user interacts (say) with a simple GUI generated by the app.
It could be argued that such information can simply be provided as _another_ command line argument;, this is true but the ability to provide fundamentally different user experiences or behaviors by using modifier keys is potentially valuable. Being able to simply press `Shift-Enter` or `Ctrl-Enter` etc for a user busy with complicated command line sessions could be something quite valuable, the ease with which a user can do this compared to remembering and typing (correctly) some additional argument is hopefully, evident.
Only `Shift `it seems, is unused at present (On Windows `Alt-Enter` maximizes the current console Window, it does not start the app and `Ctrl-Enter` does nothing) but even this is potentially useful.
`Enter `and `Shift-Enter` behave identically, the app gets started and can access its command line arguments, but the app cannot distinguish between these two modes of activating it, I think it could be useful (given the increasing prevalence of command line sessions with modern development technologies) to provide a way to convey this to an app.
# Options
These strike me as the obvious options for providing this:
- An alternative, optional `Main `overload, one that provides a `ConsoleKeyInfo` parameter in addition to the `string[] args`.
- An addition to the `Environment `static class, again perhaps a member of type `ConsoleKeyInfo`.
There are of course other ways to do this but these two strike me as reasonable.
Of course this all depends upon the interface to the OS and whether that itself even makes this available, but this is my suggestion and I'm happy to provide more information/justification if requested.
Contributor guide
Assessment
This issue has not been assessed yet.