|
From: kyleg on 10 Aug 2006 09:34 Does anyboy know how to use the number pad numbers as triggers. I can get enter/return to work, but not the numbers (only the numbers on the top row of keyboard work. Need to use the numberpad. Are these considered special characters? here is what I am using for a test if keyPressed("6") then member("you 6").text="you hit 6" if keyPressed(RETURN) then member("you ENTER").text="you hit ENTER any ideas would be appreciated
From: Darrel Hoffman on 10 Aug 2006 10:04 > Does anyboy know how to use the number pad numbers as triggers. I can get > enter/return to work, but not the numbers (only the numbers on the top row of > keyboard work. Need to use the numberpad. Are these considered special > characters? > > here is what I am using for a test > > if keyPressed("6") then member("you 6").text="you hit 6" > if keyPressed(RETURN) then member("you ENTER").text="you hit ENTER keyPressed cannot distinguish between numpad kays and the ones at the top, it only cares about the actual ASCII value that comes in, which will depend on whether the user has NumLock on or not. In order to distinguish them, you need to use the keyCode. The keyCode values for the numpad are as follows: .. - 65 * - 66 - - 70 / - 77 + - 78 = (Mac only) - 81 0 - 82 1 - 83 2 - 84 3 - 85 4 - 86 5 - 87 6 - 88 7 - 89 8 - 91 9 - 92 In order to access them, you need to have an "on keyDown" handler, like so: on keyDown put the keyCode end
From: kyleg on 10 Aug 2006 10:55 A really strange thing is happening I found this example and works in authoring view but not as projector or shockwave? note this is in the moviescript so it is available at anytime during runtime -------------------------------------------------------------- --This handler checks if a key was pressed. --it uses a case statement to check the value of "the keyCode" --when a keyCode equals a value the handler triggers --remember that these values are "keyCode" commented as ASCI ------------------------------------------------------------- on keyDown case (the keyCode) of 82 member("you 0").text="you hit 0" --0 /play 65 member("you .").text="you hit ."--. / pause 36 sprite(4).ink=36 & member("you ENTER").text="you hit ENTER" -- enter 88 member("you 6").text="you hit 6"--6 /jump ahead 86 member("you 4").text="you hit 4"--4 /jump back end case end what is strange is that the key code of 36 that has the ink change works when this thing is compiled as .exe or .dcr Below is actually a 2nd question: what does not work (because I have the wrong syntax i guess), is running both events off of key code 36. With if then statements you could use an "&" as the seperater and have more than 1 thing happen. Can this even be done with case within Lingo? reccomendations?:confused;
From: kyleg on 10 Aug 2006 13:41 It seems that case statements using num keys have issues at runtime for some events. I have some luck with this method instead -------longer but works on keyDown if the keyCode = 82 then member("you 0").text="you hit 0" --num0 /play if the keyCode = 29 then member("you 0").text="you hit 0" --0 / play ---------- if the keyCode = 76 then member("you ENTER").text="you hit ENTER"--num enter if the keyCode = 36 then member("you ENTER").text="you hit ENTER"--enter -- if keyPressed(RETURN) then member("you ENTER").text="you hit ENTER"--enter if the keyCode = 36 then sprite(4).ink=6 -- xtra action for enter ----------- if the keyCode = 65 then member("you .").text="you hit ."-- num. / pause if the keyCode = 47 then member("you .").text="you hit ."--. / pause --------------- if the keyCode = 88 then member("you 6").text="you hit 6"-- num6 / next if the keyCode = 22 then member("you 6").text="you hit 6"-- 6 / next -------------- if the keyCode = 86 then member("you 4").text="you hit 4"-- num4 / previous if the keyCode = 21 then member("you 4").text="you hit 4"-- 4 / previous end if end if end if end if end if end if end if end if end if end if end if end for anybody wondering ---- 76 is the keycode for numpad's enter. This is not documented and can not be tested with the message window as numb enter is keyboard shortcut for stop running current project. I used this to find it. on keydown member("findit").text = "" & the keyCode thanks Darrel for your earlier help!
From: Darrel Hoffman on 10 Aug 2006 15:32 > on keyDown > > case (the keyCode) of > 82 member("you 0").text="you hit 0" --0 /play > 65 member("you .").text="you hit ."--. / pause > > 36 sprite(4).ink=36 & member("you ENTER").text="you hit ENTER" -- enter > 88 member("you 6").text="you hit 6"--6 /jump ahead > 86 member("you 4").text="you hit 4"--4 /jump back > end case > end You can't do two commands on the same line. Move the other to the next line, like so: on keyDown case (the keyCode) of 82: member("you 0").text="you hit 0" --0 /play 65: member("you .").text="you hit ."--. / pause 36: sprite(4).ink=36 member("you ENTER").text="you hit ENTER" -- enter 88: member("you 6").text="you hit 6"--6 /jump ahead 86: member("you 4").text="you hit 4"--4 /jump back end case end The & operator is the string concatinator, so I'm surprised this didn't simply error out instead. But the above code should work. I think. (Not sure if the browser will capture the Enter key before the Shockwave does. A lot of keys have that problem in Shockwave.)
|
Pages: 1 Prev: How to create special effects? Next: Simple openFile script |