V
V
vladislaav2020-05-16 12:12:22
C++ / C#
vladislaav, 2020-05-16 12:12:22

How to add multiple CASE values?

I have a while loop and a switch in it that reads keystrokes. For example, for the right arrow I use case 77, and for the left arrow I use case 75. I would like to create one case for several buttons at once, for example for D, d, B, in and the right arrow. How can this be implemented? (Is it possible to create an array, write down the desired values ​​and use it? What are the options so as not to load the program with unnecessary cases)?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander, 2020-05-16
@NeiroNx

switch(keyCode){
case 77:
case 78:
case 79:
 ...
break;
case 90:
case 91:
...
break;
}

Another does not want to learn the basics of the language.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question