void __fastcall TForm1::Timer2Timer(TObject *Sender) { if (KEYDOWN(32)) { Событие } } 

How to set a range in place of a single-key code?

  • one
    write something like if (KEYUP(32) | KEYUP(100) | KEYUP(122)) ? - KoVadim

1 answer 1

What does KEYDOWN do? I did not find it in Google.

Now in the case: if you need a range, you can write an auxiliary function that runs through the entire range and performs a KEYDOWN check with each element of the range:

 bool KeyDownRange(int start, int end) { for (int i = start; i <= end; i++) { if (KEYDOWN(i)) { return true; } } return false; } 

And then in your function:

 void __fastcall TForm1::Timer2Timer(TObject *Sender) { if (KeDownRange(32, 64)) { Событие } } 
  • [BCC32 Error] Unit1.cpp (46): E2141 Declaration syntax error - Dima
  • [BCC32 Error] Unit1.cpp (55): E2219 Wrong number of arguments in call of macro 'KEYDOWN' - Dima
  • {int c; int w = 15; for (c = 0; c <= 3; c ++) {w ++; if (KEYDOWN (w)) {Timer1-> Enabled = false; }}} This is how it works. - Dima