I am creating a c++ .net program which needs to check which button on the keyboard has been pressed. My ideal way to do this is to use an array to store the Keys::__ values so that I can check each through a loop.
I think my problem is that I do not know the data type to create the array with.
My code at the moment is something like:
1 2 3 4 5 6 7 8 9 10
array<char>^ buttonMap = gcnew array<char>(Keys);
buttonMap[0] = Keys::Q;
buttonMap[1] = Keys::W;
// [tab]QWERTYUIOP[]\ /
if (e->KeyCode == buttonMap[0]) { // this is how I would like to access the value, although it will eventually be done in a loop
codeBox->Text = codeBox->Text+"ln(";
}
if (e->KeyCode == Keys::W) { // How it currently works, but this will not enable me to use a loop to run through all characters.
codeBox->Text = codeBox->Text+"log(";
}
Ok, I've looked into this a bit further and this would not quite work as I need to map the enum values to specific positions in the array. I have modified my code to the following, but this does not seem to work.
haha! You're a legend! It works perfectly! hmm, you have no idea how many different combinations and permutations I tried - as always it looks exceedingly easy and simple when figured out!