title: How write GLUT keyboard functions?
body: <p>I wrote the code below, but at runtime, when I press keys, the program doesn't work.<br>
  I want to write a program that draws a triangle when the user presses <code>right_key</code> and <code>alt_key</code>. But this doesn't work at all. It always shows a black screen.</p>
  
  <pre><code>#include &lt;GL/glut.h&gt;
  void init (void)
  {
      glClearColor(0.0,0.0,0.0,0.0);
      glMatrixMode(GL_PROJECTION);
      gluOrtho2D(0.0,200.0,0.0,200.0);
  }
  float red=1,green=1,blue=1;
  void processSpecialKeys(int key, int x, int y) {
      if(key=='0')
          exit(0);
      int mod;
      if(key== GLUT_KEY_RIGHT) {
          mod = glutGetModifiers();
          if (mod==GLUT_ACTIVE_ALT) {
              red = 1.0; green = 0.0; blue = 0.0;
              glColor3f(red,green,blue);
              glBegin(GL_TRIANGLES);
              glVertex2f(0,0);
              glVertex2f(0,100);
              glVertex2f(50,100);
              glEnd();
          }
      }
  }
  void display(void)
  {
      glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
      glFlush();
  }
  int main(int argc, char **argv)
  {
      glutInit(&amp;argc, argv);
      glutInitDisplayMode(GLUT_SINGLE|GLUT_RGB);
      glutInitWindowPosition(50,20);
      glutInitWindowSize(400, 300);
      glutCreateWindow("A simple example");
      init();
      glutDisplayFunc(display);
      glutSpecialFunc(processSpecialKeys);
      glutMainLoop();
  }
  </code></pre>