Questions tagged [console.readkey]

52 questions
12
votes
2 answers

Readkey in Java

I am new to Java ... is there a similar method to the ReadKey() in C# to avoid that a console application closes? thanks
mouthpiec
  • 3,923
  • 18
  • 54
  • 73
8
votes
2 answers

how To check if CTRL key is pressed in console application c#

I'm Going to start a console application. The problem is how to determine that the CTRL key is pressed alone without any other key. using System; using System.Text; public class ConsoleKeyExample { public static void Main() { …
Nautilus
  • 81
  • 1
  • 3
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
8
votes
3 answers

Single character console input in java/clojure

How can I read a single character/key from the console without having to hit Enter? There is an old entry in Sun's bug database claiming that it can't be done in pure java. I've found these approaches JNI JLine…
Adam Schmideg
  • 10,590
  • 10
  • 53
  • 83
6
votes
3 answers

C# Console.ReadLine after ReadKey waits for input two times

I don't understand what I am missing here, but it seems that Console.ReadKey() is still active and is causing the Console to make me enter twice when using Console.ReadLine() after invoking Console.ReadKey(). I've searched up and down how to escape…
Autonomic
  • 150
  • 4
  • 15
6
votes
4 answers

How do I convert a Console.Readkey to an int c#

I am trying to convert a user input key to an int, the user will be entering a number between 1 and 6. This is what i have so far sitting inside a method, its not working, yet throwing a format exception was unhandled. var UserInput =…
astro8891
  • 502
  • 2
  • 7
  • 18
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
3
votes
5 answers

Is there an equivelant for Pascal's readkey; in C or C++?

I am looking for a Console function that waits for the user to press a key. I want it to be like Pascal's readkey; as in a Console Only solution. No GUI library / Graphics Library / Windowing Library / WinApi Calls (Windows). It should be…
ApprenticeHacker
  • 21,351
  • 27
  • 103
  • 153
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…
2
votes
3 answers

Reading Unicode with Console.ReadKey

Is it possible to provide Unicode input to a console app, and read the Unicode char/string via Console.ReadKey()? I know Unicode works when reading the input via other methods, but unfortunately I need to use the 'interception' feature provided by…
leppie
  • 115,091
  • 17
  • 196
  • 297
2
votes
2 answers

How to keep checking if a user presses esc while Reading lines?

I want to keep reading lines of the user, but when this user presses on escape I want it to stop. But how can I keep reading single keys (for the escape), while meanwhile reading lines? I hope the question will be more clear after giving my…
wouter
  • 359
  • 4
  • 15
1
vote
1 answer

how to bind a specific key to a specific action by using Console.ReadKey() method

how to make the action happen when a certain key is pressed? can this be done with Console.ReadKey(); The code does not work! this is just a schematic image so you can understand what I mean static void Play() { if (Console.ReadKey() == 'q') …
Volodymyr
  • 82
  • 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
1 answer

How to capture stdin of a console application written in C# which contains Console.ReadKey() through python script using subprocess.Popen()

I have a console application that is written in C#. I am trying to automate its execution using python script. The console application uses Console.ReadKey() instead of Console.ReadLine() or Console.Read(). I am getting invalid operation exception…
Aditya Nadig
  • 203
  • 3
  • 12
1
vote
3 answers

C# Console.ReadKey read numbers greater than 9

Im working with ConsoleKeyInfo in C# but i have problems with Console.ReadKey when I try to write numbers greater than 9 in the console, for example ConsoleKeyInfo number; Console.Write("Write a number: "); number = Console.ReadKey(); If i want to…
elmer
  • 11
  • 1
  • 2
1
2 3 4