伙计们正在做一个程序,当按下一个键后释放时应该按下另一个键。比如如果你松开一个“a”键程序应该按“d”,如果是“d”,“a”。我将非常感谢您的回答。
这是我的代码
#include <iostream>
#include <windows.h>
#include <conio.h>
//#include<stdlib.h>
bool isOn = false;
//bool a = false;
//bool d = false;
#include "Header.h"
void OnOff();
void Action();
int main()
{
printf("Press: Home to start\n");
while (true)
{
OnOff();
if (isOn)
Action();
//std::cout << a << "," << d << std::endl;
}
}
void Action()
{
// code should be here
}
void OnOff()
{
if (_kbhit()) {
switch (_getch())
{
case 71:
if (!isOn)
{
printf("ON\n");
isOn = true;
break;
}
else if (isOn)
{
printf("OFF\n");
isOn = false;
break;
}
}
}
}