Page 1 of 1

Get keyboard press key

Posted: Fri Apr 23, 2004 11:44 am
by Wolf
Hi

How can i get one key when user press that in keyboard ?

Posted: Fri Apr 23, 2004 1:05 pm
by LarsG
ExamineKeyboard()
Result = KeyboardPushed(KeyID)

Posted: Fri Apr 23, 2004 1:22 pm
by Sunny
To check one special key, use this commands:

Code: Select all

initkeyboard()

;inits and co.

;start-mainloop

examinekeyboard()
if keyboardpushed(#PB_Key_Space)
  ;do this, after key-space was pushed
endif

;end-mainloop


Posted: Fri Apr 23, 2004 3:49 pm
by Kale
Sunny wrote:To check one special key, use this commands:

Code: Select all

initkeyboard()
;inits and co.
;start-mainloop
examinekeyboard()
if keyboardpushed(#PB_Key_Space)
  ;do this, after key-space was pushed
endif
;end-mainloop
Remember when you use the above InitKeyboard(), ExamineKeyboard(), etc.. DirectX v7+ must be installed! You can use the Win32 API to avoid the need of having DX installed. See: viewtopic.php?t=9437 I think there was a native command added in v3.90 to do this, check the history.txt file and Reference.

Posted: Fri Apr 23, 2004 9:35 pm
by Wolf
Thanks LarsG, Sunny and Kale .

But if i use of :

ExamineKeyboard()
Result = KeyboardPushed(KeyID)

It's fast do and end my prog. must use it with loop commands ?

I want if user press one button and hold i can count that character !

How can do this ?

Posted: Sat Apr 24, 2004 4:13 pm
by LarsG
you would probably have to use somethign like this:

Code: Select all

a.l = 0
Repeat

  ExamineKeyboard()
  If KeyboardPushed(#PB_KEY_SPACE)
    a +1
  EndIf
Until KeyboardPushed(#PB_KEY_ESCAPE)
note: I don't think this will only work if you open a (windowed)screen..

Posted: Sat Apr 24, 2004 10:18 pm
by Wolf
Thanks LarsG.

I must realy use it with one window ? my prog not have the window :(

Posted: Sat Apr 24, 2004 11:45 pm
by LarsG
then you can do a search on this forum for an api call byt the name of GetASyncState or GetASyncKey or something like that.. someone else may ellaborate on this some more..

Posted: Sun Apr 25, 2004 8:49 am
by PB
> do a search on this forum for [...] GetASyncState

See here: viewtopic.php?t=8366