title: Detecting keydown and keyup events on Linux C++
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/8276394/access-keystrokes-in-c">Access Keystrokes in C</a><br>
    <a href="https://stackoverflow.com/questions/12746869/monitoring-keyboard-keys-in-ubuntu">Monitoring Keyboard keys in Ubuntu</a>  </p>
  </blockquote>
  
  
  
  <p>I want to detect and time stamp every keydown and keyup event in a program (Yes, I mean <em>keydown</em> and <em>keyup</em> not just keypress) along with what key was pressed. I could do this by using an APi such as GTK, but I want to get as simple and low level as possible in order to avoid overhead from the libraries affecting the times as well as writing less code.</p>
  
  <p>I have been googling this for a while and so far have found a ton of stuff about how to do it on Windows, which doesn't help me since I am using a Linux system, and how to detect a key press on Linux, but not keyup keydown.</p>
  
  <p>Can anyone tell me what syscall, library, etc. I would need to use in order to capture the keydown and keyup events on a Linux system with a commandline program in C++? And if you have a link to a tutorial or a code example it would be most appreciated.</p>