title: C/C++ Get key pressed without polling
body: <p>I am learning C/C++ and I recently created a key-logger, mostly because it is a simple project for learning. So what I do is run <code>GetAsynKeyState()</code> in a loop to check for the status of a key. When I check the CPU its cycles spike because well; I am constantly running a loop with a conditional in it.</p>
  
  <p>It seems to me wasteful to do this kind of thing, I am sure that bigger more advanced software don't use this kind of technique.</p>
  
  <p><strong>Question:</strong> When a key is pressed an interrupt is created for the kernel to handle. Can my program be 'woken up' like the kernel is, or is the only solution constantly checking for a pressed key? What would a professional application do?</p>
  
  <p>Additionally, programming languages implement en event listener, how do they accomplish this, polling or some other magic?</p>