troubleshooting Question

VIsual Studio 2005 C++ arrowkey capture, help me make more progress in my console wordprocessor

Avatar of jim_pugh
jim_pugh asked on
C++Visual C++.NETEditors IDEs
2 Comments1 Solution582 ViewsLast Modified:
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)
ASKER CERTIFIED SOLUTION
Jase-Coder

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 2 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 2 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros