UtilKeyboardGetKeyCode Method
Translate a character to the corresponding keycode.
Namespace: DevCase.Core.IO.Devices.InputAssembly: DevCase.net48 (in DevCase.net48.dll) Version: 6.0.0.0 (6.0)
XMLNS for XAML: Not mapped to an xmlns.
public static short GetKeyCode(
char c,
IntPtr keyboardLayout = default
)
Public Shared Function GetKeyCode (
c As Char,
Optional keyboardLayout As IntPtr = Nothing
) As Short
Dim c As Char
Dim keyboardLayout As IntPtr
Dim returnValue As Short
returnValue = UtilKeyboard.GetKeyCode(c,
keyboardLayout)
public:
static short GetKeyCode(
wchar_t c,
IntPtr keyboardLayout = IntPtr()
)
static member GetKeyCode :
c : char *
?keyboardLayout : IntPtr
(* Defaults:
let _keyboardLayout = defaultArg keyboardLayout new IntPtr()
*)
-> int16
No code example is currently available or this language may not be supported.
- c Char
-
The character.
- keyboardLayout IntPtr (Optional)
-
The keyboard layout.
Int16
If the function succeeds, the return value contains the keycode.
If the function finds no key that translates to the passed character code,
the return value is
-1.
This is a code example.
No code example is currently available or this language may not be supported.
MsgBox(GetKeyCode("a"c)) ' Result: 65
MsgBox(GetKeyCode("á"c)) ' Result: 65
MsgBox(GetKeyCode("á"c, IntPtr.Zero)) ' Result: 65
MsgBox(GetKeyCode("a"c, Process.GetCurrentProcess.MainWindowHandle)) ' Result: 65
Dim sb As New Global.System.Text.StringBuilder
Dim chars As Char() = "ABCDEFGHIJKLMNOPQRSTUVWXYZ ñÑçÇ áéíóú ÁÉÍÓÚ àèìòù ÀÈÌÒÙ äëïÖÜ ÄËÏÖÜ º\'¡`+´-.,ª!·$%&/()=?¿<>".ToCharArray
For Each c As Char In chars
sb.AppendFormat("Character: {0}", CStr(c))
sb.AppendLine()
sb.AppendFormat("KeyCode : {0}", CStr(DevCase.IO.Tools.Keyboard.GetKeyCode(c, IntPtr.Zero)))
MessageBox.Show(sb.ToString())
sb.Clear()
Next c
No code example is currently available or this language may not be supported.
No code example is currently available or this language may not be supported.
No code example is currently available or this language may not be supported.
No code example is currently available or this language may not be supported.