version 2003
PA_GetKey (params) char
Parameter | Type | Description | |
params | PA_PluginParameters | Parameters received in PluginMain |
Description
The routine PA_GetKey returns the ASCII code (depending on default settings or on previous calls to PA_UseAnsiCharacters or PA_UseMacCharacters) the area received when the user presses a key, at eAE_KeyDown event.
params is the PA_PluginParameters that the plug-in received in its PluginMain routine.
This routine must be called when PA_GetAreaEvent returns eAE_KeyDown. Otherwise, it returns 0 and PA_GetLastError returns eER_BadEventCall.
Example
Fill a buffer with the keys pressed, until the buffer is full or "@" (ASCII 64) is pressed.
// The global buffer. We must use a global buffer between 2 calls, // our local variables are cleared. We usually use a buffer stored in // the area reference (see PA_Get/SetAreaReference) char gBuffer[256]; short gBufferSize = 0; /* . . . some code . . . */ void UserHitsKey (PA_PluginParameters params) { char key = PA_GetKey(params); if( (PA_GetLasterror() == eER_NoErr) && key ) { gBuffer[ gBufferSize++ ] = key; gBuffer[gBufferSize] = (char) 0; // null terminated string // Do something with the buffer if necessary // (assuming DoWithBuffer resets gBufferSize) if( (gBufferSize == 256) || (key == 64) ) DoWithBuffer( gBuffer ); } }
See Also
Create and use an external area, PA_GetClick.
Error Handling
Use PA_GetLastError to see if an error occurred (eER_BadEventCall)