This article applies to:
E-Prime 3.0
E-Prime 2.0
This item was introduced in E-Prime 2.0 (2.0.1.14).
Detail
The following code showcases the ability to obtain the current press/release state of a given key from KeyboardDevice. The following values are returned: ebStatePress (1) for down/press and ebStateRelease (0) for up/release.
' Example code
Dim nState as Integer
nState = Keyboard.GetKeyState("{SPACE}")
Debug.Print nState
nState = Keyboard.GetKeyState("a")
Debug.Print nState
nState = Keyboard.GetKeyState("1")
Debug.Print nState
If Keyboard.GetKeyState("1") = 1 Then Debug.Print "The 1 key is down"
For more information view the E-Prime Command Reference for specifics involving E-Basic (https://pstnet.com/ecr).
Legacy End User Comments
Dan Barlow 3/29/2012 14:51 | This example does not work as shown. All three GetKeyState commands must be Keyboard.GetKeyState. Also, the page should specify that this only works as shown assigning to a variable. Trying to do if (Keyboard.GetKeyState("a")=1) then ... will give an error message. |
Brandon Cernicky 9/10/2012 15:36 | Correct, the KB has been updated to use Keyboard.GetState However, you can use Keyboard.GetState w/o a specific assignment. Using If Keyboard.GetKeyState("1") = 1 Then Debug.Print "The 1 key is down" should work acceptable as well as Debug.Print Keyboard.GetState("1"). While most programming languages require/encourage the use of parens in IF statements, E-Basic (and other basic family) treat the parens as "by value" and may cause some issues. |
Comments
0 comments
Please sign in to leave a comment.