jim_pugh
asked on
VIsual Studio 2005 C++ arrowkey capture, help me make more progress in my console wordprocessor
I use Visual Studio 2005 and I have have trouble capturing the arrow keys on my console word processor project. I got a far a capturing them but when I press shift + H it thinks I am pressing the up key. Why when the up key is clearly \0H (null H) and not shift H> wierd. Maybe I need to use a string and not a char to store the keypresses.
Here a code fragment:
if (_kbhit())
{
keyPress = _getch();
if (keyPress != '\0')
{
if (keyPress >= 32 && keyPress <= 127)
{
if (keyPress == '\0H') //up key pressed
{
if (arrayIndex != 0) // if not a TOP
{
y--; arrayIndex--;
if (x > m.len(line,arrayIndex) + (boxX +1))
{
x = (m.len(line,arrayIndex) + (boxX +1));
stringIndex = m.len(line,arrayIndex);
}
m.gotoxy(x,y);
}
}
else if (keyPress == '\0P') //down
{
}
else if (keyPress == '\0M') //right
{
}
else if (keyPress == '\0K') //left
{
}
else // not an arrow key (implmented) of function key (not implmented yet)
Here a code fragment:
if (_kbhit())
{
keyPress = _getch();
if (keyPress != '\0')
{
if (keyPress >= 32 && keyPress <= 127)
{
if (keyPress == '\0H') //up key pressed
{
if (arrayIndex != 0) // if not a TOP
{
y--; arrayIndex--;
if (x > m.len(line,arrayIndex) + (boxX +1))
{
x = (m.len(line,arrayIndex) + (boxX +1));
stringIndex = m.len(line,arrayIndex);
}
m.gotoxy(x,y);
}
}
else if (keyPress == '\0P') //down
{
}
else if (keyPress == '\0M') //right
{
}
else if (keyPress == '\0K') //left
{
}
else // not an arrow key (implmented) of function key (not implmented yet)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
cout << char(int) ;
rather than cout << char;
and save it to my array the same way.