Respond to Key Presses

guclusat

Tanınmış Üye
Süper Moderatör
Respond to Key Presses
In AutoPlay Media Studio, there is an event called On Key. This event is launched whenever a key is pressed. This is useful if you want your application to, for example, play a sound every time the user presses a key.

Another use for this event is to do something only when a specific key is pressed. As an example, consider Internet Explorer. A user types in a URL into the address bar, and when they press enter, the page they requested is loaded.

To accomplish this example in AutoPlay Media Studio:

  1. Create an input object. In it's On Key event, input the following code:
Kod:
-- e_Key is a built in variable that gets generated by the On Key event.
-- 13 is the virtual key code value for the [Enter] key.

if e_Key == 13 then
    -- Load the address that was input by the user:
    Web.LoadURL("Web1", Input.GetText("Input1"));
end
Note: This script assumes that you have an input object named "Input1" and a web object named "Web1".

This script reads every key pressed by the user while in the input box. When [enter] is pressed, the script loads the URL.
 
Yukarı