标签: readkey

如何等待R中的按键?

我想暂停我的R脚本,直到用户按下一个键.

我该怎么做呢?

r keypress readline wait readkey

123
推荐指数
4
解决办法
8万
查看次数

Java:从控制台读取密钥而不按回车键

我想在用户按特定键时中断程序.我尝试下面的代码,但它只能使用回车键.

java.io.InputStreamReader reader = new java.io.InputStreamReader(System.in); 
boolean b = false;
while(!b) 
{ 
    try{
        if ( reader.ready()) 
        { 
            // read a character and process it 
            System.out.println("key pressed");
            b = true;
        } 
    }
    catch (java.io.IOException ioex)
    {
        System.out.println("IO Exception");
    }

    // edit, lets not hog any cpu time 
    try 
    { 
        Thread.sleep(50); 
        System.out.println("nop yet");
    } 
    catch (InterruptedException ex) 
    { 
        // can't do much about it can we? Ignoring  
        System.out.println("Interrupted Exception");
    } 
}
Run Code Online (Sandbox Code Playgroud)

相当于C#(工作):

    ConsoleKeyInfo k1 = new ConsoleKeyInfo('T', ConsoleKey.T, false, false, false);
    ConsoleKeyInfo …
Run Code Online (Sandbox Code Playgroud)

java console input readkey

6
推荐指数
0
解决办法
2万
查看次数

没有按下按键时,ReadKey会执行某些操作

我试图运行我的代码直到Esc被按下.因此我ReadKey在我的控制台中使用

var input = Console.ReadKey();
do
{

} while (input.Key != ConsoleKey.Escape);
Run Code Online (Sandbox Code Playgroud)

但是在"ConsoleKey"它说,在'bool'中不可能使用ConsoleKey.我该如何解决这个问题?或者我应该使用什么呢?

c# console console-application console.readkey readkey

5
推荐指数
2
解决办法
7998
查看次数

Perl Term :: ReadKey with Arrow Keys

我在ReadMode('cbreak')中使用Term :: ReadKey来读取单个字符并根据输入执行操作.这适用于箭头键以外的所有其他键.当按下箭头键时,动作执行3次,我明白这是因为箭头键转换为'^ [[A'等...

如何将箭头键转换为ReadKey可以解释的任意单个值?

我尝试了以下代码,但它不起作用:

use Term::ReadKey;

ReadMode('cbreak');

my $keystroke = '';

while ($keystroke ne 'h') {

    print "Enter key: "; 

    #Read user keystroke 
    $keystroke = ReadKey(0);

    chomp($keystroke);


    if(ord($keystroke) == 27) {
         $keystroke = ('0');
    }
}
Run Code Online (Sandbox Code Playgroud)

这是基于建议的代码:

use Term::RawInput;
use strict;
use warnings;

my $keystroke = '';
my $special = ''; 

while(lc($keystroke) ne 'i' && lc($keystroke) ne 't'){

    my $promptp = "Enter key: ";

    ($keystroke,$special) = rawInput($promptp, 1);

    if ($keystroke ne '') {
        print "You hit the normal …
Run Code Online (Sandbox Code Playgroud)

perl console.readkey readkey

5
推荐指数
1
解决办法
1918
查看次数

Console.ReadKey 取消

可能的重复:
如何向 Console.ReadLine() 添加超时?

如果我有一个 Console.ReadKey(),它会使整个程序卡住,我怎样才能让它读取密钥 1 秒,如果未读取密钥,则会设置其他内容。

c# readkey

1
推荐指数
3
解决办法
6566
查看次数