This example resets the shift state to release all pressed keys.
#include <stdio.h>
#include <unikbd.h>
int main(void) {
KHAND kbdhandle;
KBDNAME *kbd_name;
ULONG mode = 0;
USHIFTSTATE Uss = {0};/* indicates no shift keys, toggle keys,
dead keys, or layer keys are pressed.
*/
ULONG type;
APIRET rc;
/***************************************************/
/* Create a keyboard handle for US keyboard layout */
/***************************************************/
kbd_name = (UniChar*)L"us";
rc = UniCreateKeyboard( &kbdhandle, kbd_name, mode );
if ( rc != ULS_SUCCESS ) {
printf("UniCreateKeyboard error: return code = %u\n", rc );
return 1;
}
Uss.Shift = KBD_LEFTSHIFT | KBD_SHIFT; /*actual state is Left shift key*/
Uss.Effective = KBD_SHIFT; /*effective state is shift key */
type = KEYEV_ZERO;/*Reset shift state status to indicate the release of all
pressed and locked keys*/
rc = UniResetShiftState( kbdhandle, &Uss, type );
if ( rc != ULS_SUCCESS ) {
printf("UniResetShiftState error: return code = %u\n", rc );
return 1;
}
return ULS_SUCCESS;
}