Description

Module for capturing pressed keys. It utilizes RAWINPUT structure delivered by Windows OS. The module recognizes keys from 0-9 and a-z, other keys (and key combinations) are not recognized and marked as ?.

Module functions

UKeyboard.StartCapturing() - start capturing pressed keys from the whole operating system (function creates an invisible window),
UKeyboard.StopCapturing() - stop capturing pressed keys,
UKeyboard.unreadPress - information whether there is an unread key press (set to 1 after every key press, reading slots lastKey and modKey resets information to 0),
UKeyboard.lastKey - last pressed key (stored as a string),
UKeyboard.modKey - last pressed key (stored as a string), after reading the slot, its value is reset to "" (empty string), which means that there are no unread pressed keys.

Urbiscript example

// init module
loadModule("UKeyboard");
var Global.keyboard = ("UKeyboard");
//start capturing key presses
keyboard.StartCapturing(),
//reading value of pressed key with modKey slot - assume that "a" key was pressed
echo(keyboard.unreadPress);//prints 1
echo(keyboard.modKey);//prints a
 
echo(keyboard.unreadPress);//prints 0
echo(keyboard.modKey);//prints nothing (empty string)
//reading value of pressed key with lastKey slot - assume that "b" key was pressed
echo(keyboard.unreadPress);//prints 1
echo(keyboard.lastKey);//prints b
 
echo(keyboard.unreadPress);//prints 0
echo(keyboard.lastKey);//prints b
//stop capturing key presses
 
//"a" key was pressed
echo(keyboard.modKey);//prints a
echo(keyboard.lastKey);//prints a
 
keyboard.StopCapturing();
 
//"b" key was pressed, but it will not be captured by the module
echo(keyboard.modKey);//prints nothing (empty string)
echo(keyboard.lastKey);//prints a
 

Download

LINK

 

 

EMYS and FLASH are Open Source and distributed according to the GPL v2.0 © Rev. 0.8.0, 27.04.2016

FLASH Documentation