Page 1 of 1

press both two arrows keys

Posted: Sat Dec 05, 2015 1:01 am
by problème
Hello,

I would want to know how to do for have as information , if the user press both the arrow key right and the arrow key up .
I would make a call different command if the user press only arrow right.

Code: Select all

on arrow key k
  test k
end arrow key 

command test k
  if k is "right" then
   command1
  else -- if the user press arrow key up + right 
   command2
   end if
end command


Re: press both two arrows keys

Posted: Sat Dec 05, 2015 4:18 am
by dunbarx
Hi.

The arrowKey messages are sent as each is pressed in turn, so you cannot collect them in a serial way. You can always do something like:

Code: Select all

on arrowkey var
   if var = "left" then put "left" after fld 1
   if  var = "down" then put "down" after fld 1
end arrowkey
But this would require a bit more management

Craig

Re: press both two arrows keys

Posted: Sat Dec 05, 2015 5:11 pm
by problème
thanks for your help

Re: press both two arrows keys

Posted: Sat Dec 05, 2015 8:28 pm
by Newbie4
The keysdown does register the arrow keys which have the following number codes:
left = 65361
up = 65362
right = 65363
down = 65364

To see the key codes, copy the following to your card script:

Code: Select all

on updateScreen
   put keysdown( ) into msg
   send updateScreen to me in 20 millisec
end updateScreen
Then add a button:

Code: Select all

on mouseUp
   updateScreen
end mouseUp
It will show you the codes for all the buttons on the keyboard as you press them.

Also, use the "set" command to move your object. It is faster than the "move" command and the 2 keys (up and right - or whatever) will not look disjointed

(You might also get some more answers and ideas here: https://sites.google.com/a/pgcps.org/li ... rogramming

Hope this helps

Re: press both two arrows keys

Posted: Sun Dec 06, 2015 9:48 pm
by richmond62
I have been playing around with my arrowKeys and have arrived at a VERY SIMPLE way of doing things:
tort.png
code.png
I have attached the stack so you can see how this works.

Re: press both two arrows keys

Posted: Tue Dec 08, 2015 6:17 pm
by problème
Thank you so much, you have saved me time.

Re: press both two arrows keys

Posted: Tue Dec 29, 2015 5:31 pm
by MaxV
Probably this is less pc clocks consuming, because you avoid infinite loops:

########CODE#######
on keydown
put keysdown() into msg
end keydown

on arrowkey
put keysdown() into msg
end arrowkey
#####END OF CODE#####