title: While loop using a lot of CPU time
body: <p>I am creating a keystroke logger for my personal interest, as well wanting to know how to capture and use them as functions (like key shortcuts).</p>
  
  <p>I got the code to learn how keylogger and GetAsyncKeyState() work <a href="http://www.rohitab.com/discuss/index.php?showtopic=9931" rel="nofollow noreferrer">here</a>.</p>
  
  <p>I got it to run under Code::Blocks, but the weirdest things is that when I check my task manager, my CPU Usage rises to 100%. When I close the program, it goes back down, and goes back up to 100% when I turn it back on.</p>
  
  <p>I presume it's because of the infinite while loop constantly checking for inputs, but I want to know if there's any way to decrease the CPU usage without losing function.</p>
  
  <p>P.S How would I make a key shortcut? For example, pressing <kbd>Ctrl</kbd>+<kbd>E</kbd> to make the program exit.</p>