ReadKey() is a console method for obtaining the next character pressed by the user.
Questions tagged [readkey]
41 questions
1
vote
1 answer
Check ReadKey only for letters (alphabet) in string
i am doing game "Hangman" but i have a problem. I am using ReadKey to find the guess of player, but he can use even numbers or buttons like "Enter" etc. I want to stop this, but i don't know how :/ Can you help me please? I want control, if in…

Jan Kocvik
- 41
- 9
1
vote
7 answers
Two-condition While loop, one of which ends program
I have some code which exits the program when the user types 'q'
//press 'q' to quit application
ConsoleKeyInfo info = Console.ReadKey(true); ;
while (info.KeyChar != 'q') {
info = Console.ReadKey(true);
}
How do I modify this structure so that…

John Smith
- 95
- 5
1
vote
1 answer
Readkey() in java : how to do it?
I worked with Pascal and now I'm trying to understand if there is (in java) something similar of the Pascal readkey() command.
I've searched it but I haven't found anything good, only answer like this:
try
{
…

VinceLomba
- 398
- 2
- 8
- 18
1
vote
2 answers
readkey command in python
I want my Python program to stop and wait until any key is pressed, then to print the key that was just pressed.
It's like the Pascal's command key := readkey; writeln(key);.
I' ve tried yet to use the msvcrt module and the getch command but it…

VinceLomba
- 398
- 2
- 8
- 18
1
vote
1 answer
What does it mean, when Term::ReadKey::ReadKey returns "0"?
With dumpkeys --long-info called in a Linux-Terminal I get these values:
# ...
0x0000 nul
0x0001 Control_a
0x0002 Control_b
0x0003 Control_c
0x0004 Control_d
# ...
When I run this script and press Ctrl a or Ctrl b I get the corresponding…

sid_com
- 24,137
- 26
- 96
- 187
1
vote
2 answers
Term::ReadKey, "Strg+D" and STDIN
When I type after Enter a string: for example a, b, c and then two times Ctrl+D I get an endless loop which doesn't halt on ReadKey and which I can not stop with the Q key?
#!/usr/bin/env perl
use warnings;
use 5.10.1;
use Term::ReadKey;
while( 1…

sid_com
- 24,137
- 26
- 96
- 187
0
votes
1 answer
ReadKey() doesn't track keystrokes in other windows or instances
I wrote a simple script to track keys being pressed and released as shown below:
$j = 0
while($j -lt 10000){
$PressedKey = $Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown,IncludeKeyUp")
$PressedKey
continue
}
When I run it and start…
0
votes
1 answer
How to ignore "Enter" key press in C# Console Application?
using System;
using System.Text;
namespace 判断输入是否为数字
{
internal class Program
{
public static int ConsoleInputDigit(int length)
{
char[] news = new char[length];
for (int i = 0; i < news.Length; i++)
…

suyangzuo
- 75
- 2
- 8
0
votes
1 answer
ReadKey getting characters pressed before a thread timeout has ended
i'm attempting my first c# console-based game. I created a centered credits intro with a "press any key to continue..." printed at the end. I used Console.ReadKey() to emulate a pause as it waits for user input. The problem is that you can 'stack'…

RRKS101_1 TF2
- 89
- 1
- 1
- 7
0
votes
2 answers
vb.net readline or readkey don't want to stop my program
my code is working i tried it separately but the problem here is that when i'm putting them together , the readkey or readline don't stop the program and the do loop is not working too, can someone take a look please thank in advance
Dim count As…

TheMel2203
- 13
- 2
0
votes
1 answer
c# how to display next WriteLine after pressing a key
Basically in my code I want it to display the next lines after the user presses a key. I thought it was ReadKey, but after I press a key it closes.
For Example
WriteLine("Press any key to display invoice...");
ReadKey(); //this…

boothegreat
- 3
- 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
0 answers
I'm trying to mask the characters entered in the console with '*' but it is just repeatedly printin asterisks, anyone know what i can do?
using System;
class MainClass {
public static void Main (string[] args) {
Console.Write("password: ");
string password = null;
while (true){
var key = Console.ReadKey(true);
Console.Write("*");
password +=…
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
2 answers
C# - Problems with the animations, using readkey() method
I'm trying to creating an Console app that let the user control the animation of a word in the screen. Basically I show the word and then it starts moving according with the keys pressed by the user.
Its almost working but for some reasoning i…

Daniel
- 145
- 1
- 1
- 6