ReadKey() is a console method for obtaining the next character pressed by the user.
Questions tagged [readkey]
41 questions
177
votes
7 answers
How to wait for a keypress in R?
I want to pause my R script until the user presses a key.
How do I do this?

Contango
- 76,540
- 58
- 260
- 305
8
votes
4 answers
Perl Term::ReadKey with Arrow Keys
I'm using Term::ReadKey in ReadMode('cbreak') to read a single character and perform an action based on the input. This works fine for all other keys except the arrow keys. When the arrow keys are pressed, the action is performed 3 times and I…

user3821320
- 137
- 1
- 9
5
votes
3 answers
ReadKey while key is not pressed do something
I am trying to run my code until Esc was pressed. Therefore I am using ReadKey in my Console
var input = Console.ReadKey();
do
{
} while (input.Key != ConsoleKey.Escape);
but at "ConsoleKey" it says that, ConsoleKey isn't possible in 'bool'. How…

user3002135
- 237
- 1
- 4
- 15
5
votes
3 answers
Console.ReadKey canceling
Possible Duplicate:
How to add a Timeout to Console.ReadLine()?
If I have a Console.ReadKey(), It makes the whole program stuck, how can I make it so that it will read a key for 1 second, and if a key is not read, something else would be set.

user1823701
- 431
- 1
- 5
- 8
3
votes
1 answer
Why $host.UI.RawUI.ReadKey() method captures a not-really-pressed Enter key?
I want to write a function in PowerShell 7 to wait the user to press a key or a key combination (such as Alt+Ctrl+D). There are two options I can choose: The Console.ReadKey() method in .net core, and $host.UI.RawUI.ReadKey() method in PowerShell.
I…

Ding Xin
- 307
- 1
- 3
- 11
2
votes
0 answers
Task that ReadsKey from keyboard doesnt work - Consumer/Producer Pattern
I am implementing a single Producer/Consumer Pattern using BlockingCollection.
When i click 'c' from keyboard i want to cancel the operation using CancellationToken.
The strange thing is that if i press 'c' as fast as i can after i run the program,…

RoR noob
- 337
- 3
- 11
2
votes
1 answer
Perl Term::ReadKey - Read from file as though it's being typed
Been away from Perl awhile and would like to modify a script I wrote as an art project long ago. The original script uses Term::ReadKey to allow the user to type arbitrary text into a Mac/Linux terminal. As they type, the text creates various…

artistwhocodes
- 21
- 4
2
votes
1 answer
Readkey in Pascal (Unknown Identifier)
I am learning how to use the graphic mode from Pascal (Using Turbo Pascal 5.5). This is a simple code, which shows me the graphic mode with some messages:
program GraficoPri
uses Graph;
var Driver, Modo : Integer;
begin
Driver := VGA;
Modo :=…

WolfangAukang
- 21
- 1
- 4
1
vote
1 answer
PowerShell, break out of a timer with custom keypress
My timer below will countdown from $total_time down to 0, displaying a progress bar. This is fine, but how can I exit the loop and continue the script upon a custom keypress, such as 'ESC', or 'Enter', or 'Space', or 'm'?
How would I then have…

YorSubs
- 3,194
- 7
- 37
- 60
1
vote
1 answer
How to get rid of the ReadKey() que if a person where to spam a key?
My console application uses ReadKeys thruout the code; if a person where to say click a key when an ReadKey is not active, it would to my speculation be added to a que of sorts, so when the code gets to the readKey it instantly goes on the previus…

Leo Christensson
- 27
- 5
1
vote
3 answers
Console.ReadKey seems to be reading the wrong key?
I'm just starting out so I'm in the middle of writing my first console application from scratch. I have this line of code, when I hit d it correctly takes me to the next step and sets disadvantage to true, however if I hit a it executes the else…

Henry Puspurs
- 96
- 8
1
vote
1 answer
Problem in Powershell not consuming ReadKey
When using the following LOC in a custom Powershell function that essentially was a "Wait until any key is pressed" called from a script:
[System.Console]::ReadKey($true)
… later on, particularly when the function returned or completed its context…

David Jones
- 542
- 4
- 13
1
vote
0 answers
Console.ReadKey() Strange Behavior?
I'm trying to understand what is happening with Console.ReadKey() versus Console.ReadKey(true). I understand that including true will prevent the key from being displayed to the console, but there is some odd behavior produced when also using…

Bosco312
- 11
- 1
1
vote
1 answer
C++ read user input without pressing return (Mac OS X), same as readkey in Turbo Pascal
I have seen many posts about this, but none of them answer the question, they give examples that do not work, all you get is more error messages, or just sent off at other tangents. ncurses is continually mentioned yet none of the examples I have…

CpƆlCuƆsCpƆlCuƆsƆ
- 13
- 2
1
vote
0 answers
Kill/Cancel/Close ReadKey Task C#
please is there a way, how to close ReadKey task? I'm using this code in my console application:
Task _task = Task.Factory.StartNew(() => Console.ReadKey());
bool result = Task.WaitAny(new Task[] { _task },…

Blaato
- 129
- 10