title: PyOpenGL Taking keyboard input
body: <p>I'm trying to make a raycaster in Python with PyOpenGL and i accomplished to make a little yellow square. Main thing is that i need keyboard input to move my square and i made something but it is not working. Here is the code:</p>
  <pre><code>from OpenGL.GL import *
  from OpenGL.GLU import *
  from OpenGL.GLUT import *
  import sys
  import math
  
  def drawPlayer():
      glColor3f(1,1,0)
      glPointSize(8)
      glBegin(GL_POINTS)
      glVertex2i(px,py)
      glEnd()
  
  def display():
      glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
      drawPlayer()
      glutSwapBuffers()
  
  # Here is my keyboard input code
  def buttons(key,x,y):
      if key == 'a':
          px -= 5
      if key == 'd':
          px += 5
      if key == 'w':
          py -= 5
      if key == 's':
          py += 5
  
  def init():
      glClearColor(0.3,0.3,0.3,0)
      gluOrtho2D(0,1024,512,0)
      global px, py
      px = 300; py = 300
  
  def main():
      glutInit(sys.argv)
      glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB)
      glutInitWindowSize(1024, 512)
      window = glutCreateWindow(&quot;Raycaster in python&quot;)
      init()
      glutDisplayFunc(display)
      glutKeyboardFunc(buttons)
      glutMainLoop()
  
  if __name__ == &quot;__main__&quot;:
      main()
  </code></pre>
  <p>Why this code is not working?</p>