keyboard_virtual_show

This function can be used to show the virtual keyboard on the device running the game. When you call this function you need to provide one of the following constants for each of the first three arguments:

Virtual Keyboard Type Constant
Keyboard TypeDescription
kbv_type_defaultThe default keyboard type for the current system.
kbv_type_asciiAn ASCII-only keyboard.
kbv_type_urlA normal keyboard optimized for URL entry. Usually features a ".com" or other domain keys, as well as "/" and "." keys.
kbv_type_emailA normal keyboard optimized for e-mail entry. Usually features "@" and "." characters.
kbv_type_numbersA numbers-only keyboard, usually displayed as a number pad.
kbv_type_phoneA phone pad keyboard. Usually numbers-only with the "*" and "#" keys.
kbv_type_phone_nameA keyboard optimized for entering both a phone number and a name. Usually similar to an ASCII keyboard, but with a limited special characters selection.

 

Virtual Keyboard Return Type Constant
Return TypeDescription
kbv_returnkey_defaultThe default return key title for the current system.
kbv_returnkey_goSets the return key title to "Go".
kbv_returnkey_googleSets the return key title to "Google", or to a generic search icon in some cases.
kbv_returnkey_joinSets the return key title to "Go".
kbv_returnkey_nextSets the return key title to "Next".
kbv_returnkey_routeSets the return key title to "Route".
kbv_returnkey_searchSets the return key title to "Search", or to a generic search icon in some cases.
kbv_returnkey_sendSets the return key title to "Send".
kbv_returnkey_yahooSets the return key title to "Yahoo", or to a generic search icon in some cases.
kbv_returnkey_doneSets the return key title to "Done".
kbv_returnkey_continueSets the return key title to "Continue".
kbv_returnkey_emergencySets the return key title to "Emergency Call".

 

Virtual Keyboard Autocapitalization Type Constant
Autocapitalization TypeDescription
kbv_autocapitalize_noneAutocapitalization is disabled.
kbv_autocapitalize_wordsWords will be auto-capitalized.
kbv_autocapitalize_sentencesSentences will be auto-capitalized.
kbv_autocapitalize_charactersAll characters will be capitalized.

 

The last argument is to enable/disable predictive text, and this would be set to true to permit it, and false otherwise, but note that just because it is permitted doesn't mean that it will be used as that will depend on the preferences of the user on the device. When in predictive text mode, the virtual keyboard will not generate normal GameMaker keypress events. Instead, it will only update the last character pressed and keyboard string variables. This is due to the inability to detect whether a change in the internal text field used for detecting key presses came from an actual virtual keyboard key, or a text suggestion. In these cases you would want to read the keyboard_string input as opposed to reading any kind of raw key input.

It is important to note too that the user will get different keyboards with different capabilities depending on the platform OS, with the following caveats for use per target:

Unavailable return keyReplacement key
kbv_returnkey_google
kbv_returnkey_yahoo
kbv_returnkey_search
kbv_returnkey_join
kbv_returnkey_route
kbv_returnkey_emergency
kbv_returnkey_go
kbv_returnkey_continuekbv_returnkey_next

 

Calling this function will generate a System Asynchronous Event, in which the async_load DS map will be populated with the following key/value pairs:

 

Syntax

keyboard_virtual_show(keyboard_type, return_key_type, autocapitalization_type, predictive_text_enabled);

ArgumentTypeDescription
keyboard_typeVirtual Keyboard Type ConstantDetermines the keyset available on the virtual keyboard (see tables at the top).
return_key_typeVirtual Keyboard Return Type ConstantDetermines what is shown on the return/action key of the virtual keyboard (see tables at the top).
autocapitalization_typeVirtual Keyboard Autocapitalization Type ConstantDetermines how/if the words typed via the virtual keyboard will be autocapitalized (see tables at the top).
predictive_text_enabledBooleanSet to true/false to enable/disable predictive text input.

 

Returns:

N/A

 

Example:

if (input == false)
{
    input = true;
    keyboard_virtual_show(kbv_type_numbers, kbv_returnkey_default, kbv_autocapitalize_none, false);
}

The above code will bring up the OS virtual keyboard if the given variable is not set to true.