Page 1 of 1
OnKeyPress question
Posted: Wed May 14, 2008 5:21 pm
by Fazer
The button has an event, which is called "OnKeyPress". It works fine - I know the button must have the focus -, but how can I find out, which key is pressed?
The key table describes the key numbers for keyDown and keyUp events with a variable "key" (format WORD),
but how does this work with "OnKeyPress", because a button has no "keyDown" or "keyUp" events.
I know this from other basics but I tried it out, but every try gave an error.
How can I catch the type of the pressed key?
OnKeyPress question
Posted: Fri May 16, 2008 8:30 am
by Fazer
Yes, I found the answer by myself:
What I`m looking for works only in an edit control with the events:
? ? ? OnKeyDown ?: ?" Sub([edit,] key, shift). A sub-routine calls if a key is pressed."
? ? ? OnKeyUp ?: ?" Sub([edit,] key, shift). A sub-routine calls if a key is released."
What do we learn from this:
? ? ? ?If you have a problem read the Help - file more exactly !
The Help file of FNXBasic is not as perfect as it could be, but it does what it has to do.
?
OnKeyPress question
Posted: Fri May 16, 2008 7:34 pm
by PaPi
I know this with object EDIT. But what about the object BUTTON? You did want use with BUTTON
this events, didn`t you?
PaPi
OnKeyPress question
Posted: Sat May 17, 2008 6:04 am
by Fazer
I think a button only can see if a key is pressed, but not which key. Is this right ?
OnKeyPress question
Posted: Mon May 19, 2008 3:43 pm
by Marco
Hi you can detect which button is pressed, only the keys not the special keys.
object f as form
object b as button
onkeypress=kp
end object
end object
f.showmodal
sub kp(key as integer)
showmessage str$(key)
end sub
I hope this will help you out
best regards
OnKeyPress question
Posted: Mon May 19, 2008 8:08 pm
by Fazer
Many thanks, this helps a lot.
The Help file gives only the information:
"OnKeyPress: Sub([button]). A sub-routine calls if a key is pressed."
I looked for a "key" variable in the format "word" as described at the event "onkeydown" with the edit control.
I dont`expected an integer.
The help should give more infos.