Questions tagged [console.readkey]
52 questions
0
votes
1 answer
c# incomplete Console.ReadKey() calls I don't want the user to complete
I am learning about socket messaging. I interrupted Console.ReadKey() in a while loop and a lot of the calls ended up incomplete. I am trying to find a way to remove the incomplete calls without the user typing it all out.
I have…

Cody Harkinz
- 1
- 3
0
votes
1 answer
Console.ReadKey not reliable
I have the following code, which waits for user input via arrow keys to move, or escape to end the program.
Console.WriteLine(startNode.Render(true));
LevelState currentNode = startNode;
while (Console.ReadKey(true).Key != ConsoleKey.Escape)
{
…

NounVerber
- 135
- 7
0
votes
1 answer
Console is reading user input while code is running
I am writing a 2d, turn-based adventure game in C# that runs in windows console.
Here is a rough idea of what my game loop looks like:
while(condition) {
MethodCall1();
MethodCall2();
MethodCall3();
…

Stewcooker
- 103
- 1
- 3
0
votes
2 answers
C# Terminating the program with a key combo without pressing enter while in read
Now here is the situation we are in:
getinput:
//things happen here
string typed = Console.ReadLine();
try
if (typed == "com")
{
//things happen here
}
else if (Console.ReadKey(true).Key ==…

aGoodFellow
- 41
- 10
0
votes
4 answers
Why does Console.ReadKey().Key.ToString get lower and uppercase Letter by pressing once?
This snipet Outputs two Letters when i press one Key (r).
string key = string.Empty;
key = Console.ReadKey().Key.ToString();
Console.WriteLine(key);
Console.ReadKey();
// Output: rR
Why does it output lower 'r' and Upercase 'R' when i only press…

novski
- 196
- 1
- 11
0
votes
4 answers
In C# I am taking a char input and then I output something. But after input control is not waiting for enter and straightaway giving output
I have the following code:
using System;
namespace MyApp {
class KeyBoardInputTest {
static void Main() {
Console.Write("Enter a character >\t");
char ch = (char)Console.Read();
Console.WriteLine("");
…

puregeek
- 175
- 3
- 9
0
votes
1 answer
My program close, before i write numbers (calculating option)
I dont know why my program close before i write numbers (in calculating option). And what is wrong with labels. Someone help ? Sorry for this. It's must be easy for you.
class Program
{
static void Main(string[] args)
{
string str;
…

SebiX
- 1
- 1
0
votes
1 answer
Console.ReadKey() looping by itself in while loop
I have a loop and inside it a switch case which is basicly an user interface which lets people choose yes and now to continue a game with the left and right arrows.
i also added a Console.Beep() to give some feedback to the user. for some reason…

SuperMinefudge
- 301
- 3
- 11
0
votes
1 answer
Reading user input from powershell through scriptcs
Here I have a problem to read user inputs from Command prompt or windows powershell through scriptcs.I tried with Console.ReadLine(),Console.Read() or Console.ReadKey() wrapped it around Convert.ToString() to get user response but none of them gives…

boney
- 11
- 5
0
votes
1 answer
how can i get my console app to close whenever the esc. key is pressed throughout the app?
//Here is a snippet of my code the menu method calls on 2 more methods within, I have tried everything and don't know what code to use or where to put it. thank you guys!!
namespace ConsoleApplication7
{
class Program
{
const double pi =…
0
votes
1 answer
2 key choices on console
I'm making a game on Visual Studio on C# (in a console). It's about dialogues, and you can answer them with 2 choices, one key (for answering the first question) is 1 and the other one is 2.
The problem is that when you press one key, you can´t…

N. Muñoz
- 3
- 2
0
votes
1 answer
String printing multiple times except the last time?
Here is my code
Module Module1
Private Delegate Sub word(ByVal A As String, ByVal B As String, C As String)
Dim A, B, C As String
Sub Main()
Console.WriteLine("type something")
A = Console.ReadLine()
…

Tim The Learner
- 75
- 2
- 8
0
votes
2 answers
vb.net or c#.net console.readkey shift+number chars
I've been having some trouble getting the correct code for incoming keystrokes on the console for shift+number characters. For example, using:
cki = Console.ReadKey(True)
Console.WriteLine("You pressed the '{0}' key.", cki.Key)
If I press shift+2,…

user2088591
- 1
- 2
0
votes
0 answers
Waiting for user input using Tasks and ReadKey does not respond on the first key press
This is my main function:
var configKey = Task.Factory.StartNew(acceptConfig);
var devKey = Task.Factory.StartNew(acceptDevMode);
while (true)
{
doSomething();
if (configKey.IsCompleted)
{
getFirstChoice();
…

amiregelz
- 1,833
- 7
- 25
- 46
0
votes
1 answer
ReadKey method not working when application throws an exception
The ReadKey() method is not working when the method throws an exception? When the program runs the ReadKey method works only if the method dos not throw an exception, if the method throws an exception the console window just appears for a second or…

somethingSomething
- 830
- 7
- 20
- 43