3 Replies - 354 Views - Last Post: 28 August 2011 - 12:39 AM Rate Topic: -----

#1 farizaw  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 10
  • Joined: 27-August 11

get key

Posted 27 August 2011 - 05:05 PM

dears
I have CODEBLOCKS and I need an example to read from keyboard without waiting, the program will continue without waiting the key to be pressed and if any key was pressed it will store the code to be checked Latter.
thanks
Fariz
Is This A Good Question/Topic? 1
  • +

Replies To: get key

#2 Aphex19  Icon User is offline

  • Born again Pastafarian.
  • member icon

Reputation: 615
  • View blog
  • Posts: 1,873
  • Joined: 02-August 09

Re: get key

Posted 27 August 2011 - 05:14 PM

Try GetAsyncKeyState.
Was This Post Helpful? 0
  • +
  • -

#3 OLH064  Icon User is offline

  • Junior bit compressor

Reputation: 20
  • View blog
  • Posts: 725
  • Joined: 06-June 11

Re: get key

Posted 27 August 2011 - 07:20 PM

MS Windows uses a WINPROC() method (that you create)
that holds input for you, but can be checked at any time.
You would start a HWND, and pass a WINPROC function that you write.
Your WINPROC just looks at what it receives, because it only gets called when you pass the HINSTANCE input to its parent HWND.

GetKeyboardState is really awesome, you can grab the entire keyboard in one pass with a 256 byte array, but it's not as fast as GetAsyncKeyState, and you don't know the capture rate. (or the time it was captured)

conio has getch(), but please don't use it, it's ra-heely depreciated, and only works with a console. It only waits for one key, return counts as one, but I don't know why I wrote this here. I guess I just had the space to write about getch()?
Was This Post Helpful? 3
  • +
  • -

#4 hulla  Icon User is offline

  • Writing Lines


Reputation: 49
  • View blog
  • Posts: 732
  • Joined: 05-March 11

Re: get key

Posted 28 August 2011 - 12:39 AM

Speaking of conio.h, conio.h also has _kbhit() which checks if, well, the keyboard was hit.

I do not recommend usage of this though as it lies in conio.h and conio.h is non-standard. :shuriken:
Was This Post Helpful? 2
  • +
  • -

Page 1 of 1