help with setting keyboard keys to functions

I'm trying to make a game and the way I'm gonna do movement is a grid w/ each square numbered and I plan on setting the arow keys to add 1 or subtract 1 how would I do this?
You will need a library that deals with it. I can recommend PDCurses because it was easy to use and works on multiple platforms. If you are only interested in Windows then you could just use the WIN32 API. Drawing keys out of the Windows message pump is not all that hard but would require you to learn it. It would look something like this:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
  switch(message)
  {
    case WM_KEYDOWN:
    {
      switch(wParam)
      {
        case VK_RIGHT:
        {
          // Right arrow pressed, do something....
        } break;
        case VK_LEFT:
        {
          // Left arrow pressed, do something....
        } break;
        case VK_UP:
        {
          // Up arrow pressed, do something....
        } break;
        case VK_DOWN:
        {
          // Down arrow pressed, do something....
        } break;
      }
    }
  }
  default: return DefWindowProc(hWnd, message, wParam, lParam);
}

Thanks.
Topic archived. No new replies allowed.