0

ユーザー入力を取得し、ユーザーが入力した内容に従ってアクションを実行する関数を作成しています。ユーザーが入力した内容をチェックする case ステートメントを使用しています。

ユーザーがホーム、エンド、イン、デルを押したかどうかを確認するのが困難です。HOME、INSERT、DELETE、END などのデフォルト変数は効果がないように見えますが、LEFT と RIGHT を使用する矢印キーは効果があります。私はGNU/Linuxでこれをやっています。何が間違っているのかわかりません。

どんな助けでも大歓迎です。

4

2 に答える 2

0

これらは、キーのスキャン コード (IBM PC) を定義します。すべての数値は 10 進数です。

#define PAGE_UP     73
#define HOME        71
#define END         79
#define PAGE_DOWN   81
#define UP_ARROW    72
#define LEFT_ARROW  75
#define DOWN_ARROW  80
#define RIGHT_ARROW 77
#define F1          59
#define F2          60
#define F3          61
#define F4          62
#define F5          63
#define F6          64
#define F7          65
#define F8          66
#define F9          67
#define F10         68

#include <iostream>
#include <conio.h>

Linux スキャン コードは次のとおりです。 http://www.comptechdoc.org/os/linux/howlinuxworks/linux_hlkeycodes.html

于 2014-05-26T07:20:51.380 に答える
0

問題は次のとおりです。

#include <stdio.h>

//Compiled on GNU/Linux
//By: Saulius Grybas


int main()
{
        int key;
        bool done = false;

    while (!done)
    {

        key = getchar();

        switch (key){
                case HOME:
                        //Home key is pressed / perform action
                        done = true;
                        break;
               case END:
                        //END key is pressed / perform action
                        done = true;
                        break;
               case DEL:
                        //DEL key is presed / perform action
                        done = true;
                        break;
                case BACKSPACE:
                        //backspace is pressed / perform action
                        done = true;
                        break;
                default:
                        done = false;
                        break;
         }
                printf ("%d%s\n", key, " - Integer of key is pressed!");
    }

    return 0;
}
于 2013-09-28T23:57:29.403 に答える