This example translates a Unicode character to a scan code and creates the effective shift state.

#include <stdio.h>
#include <unikbd.h>

int main(void) {

   KHAND      kbdhandle;
   KBDNAME   *kbd_name;
   ULONG      mode     = 0;
   UniChar    unichar;
   VDKEY      vdkey = 0;
   VSCAN      pscan;
   ULONG      eshift;
   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;
   }

   /***********************************/
   /* Untranslate Unicode character A */
   /***********************************/

   unichar = 0x0041;

   rc = UniUntranslateKey( kbdhandle, unichar, vdkey, &pscan, &eshift );

   if ( rc != ULS_SUCCESS ) {
      printf("UniUntranslateKey error: return code = %u\n", rc );
      return 1;
   }

   return ULS_SUCCESS;

}


[Back: UniUntranslateKey - Remarks]
[Next: UniUntranslateKey - Topics]