title: GLUT key down and key up on CTRL key
body: <p>I've found a lot of information about using GLUT to detect whether the <kbd>Ctrl</kbd> key is pressed using the GLUT_ACTIVE_CTRL macro. This macro only works, apparently, within a keyboard or mouse callback function. I need to know whether or not the <kbd>Ctrl</kbd> key is pressed at a point in my main loop, but GLUT_ACTIVE_CTRL doesn't seem to work in this context. </p>
  
  <p>So, is there a way to detect key up and key down events on the <kbd>Ctrl</kbd> key (without any other keys being typed) in a platform independent GLUT-ish way? </p>
  
  <p>EDIT: The keyboard callback is not fired (at least for a default setup) when the <kbd>Ctrl</kbd> key is pressed. This is the basic problem, that I can only test whether the <kbd>Ctrl</kbd> key is or isn't pressed when another key is pressed and thus fires the keyboard callback. </p>
  
  <p>My setup is something like:</p>
  
  <pre><code>// ... in main function:
  glutKeyboardFunc(keyboard);
  
  //later in the code: 
  
  void keyboard(unsigned char key, int _x, int _y)
  {
      printf("keydown \n");
  
      if (glutGetModifiers() == GLUT_ACTIVE_CTRL) {
              printf("control key is pressed.\n");
      }
      //etc.
  </code></pre>
  
  <p>When I press any normal character "keydown " is printed to stdout. When I press the <kbd>Ctrl</kbd> key, nothing happens. If I press <kbd>Ctrl</kbd>+<kbd>C</kbd>, "keydown control key is pressed." is printed.</p>
  
  <p>However, in my main loop I added:</p>
  
  <pre><code>if (glutGetModifiers() == GLUT_ACTIVE_CTRL) {
      printf("Control key down.\n");
  } else {
      printf("Control key up.\n");
  }
  </code></pre>
  
  <p>and it always prints "Control key up." regardless of whether I am pressing the <kbd>Ctrl</kbd> key or not.</p>