Platforms to show: All Mac Windows Linux Cross-Platform

Back to KeyCodesMBS class.

KeyCodesMBS.AsciiToKeyCode(ascii as Integer) as Integer

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Remote Control MBS ComputerControl Plugin 2.8 ✅ Yes ✅ Yes ❌ No ❌ No Desktop only
Returns the keycode which is needed to be pressed to create this ASCII character.

You get the main key, not any modifier which may also be pressed.

Some examples using this method:

KeyCodesMBS.KeyCodeToAscii(keycode as Integer) as Integer

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Remote Control MBS ComputerControl Plugin 2.8 ✅ Yes ✅ Yes ❌ No ❌ No Desktop only
Returns the ASCII code which matches the key code.
Example
dim k as KeyCodesMBS

k=new KeyCodesMBS

// makes a big A on a german keyboard:
MsgBox chr(k.KeyCodeToAsciiWithSecondKeyCode(0+512))

Note on a Mac:
Bit 0 to 6 are the keycode, bit 7 is 1 if key goes up and 0 if key goes down.
Bit 8 to 15 are modifier keys:

Constants for the modifier keys:
shiftKey 512 shift key down?
alphaLock 1024 alpha lock down?
optionKey 2048 option key down?
controlKey 4096 control key down?
rightShiftKey 8192 right shift key down?
rightOptionKey 16384 right Option key down?
rightControlKey 32768 right Control key down?

Not available in 64-bit.
See MacTextForKeyCode method in RemoteControlMBS module.

KeyCodesMBS.KeyCodeToAsciiWithSecondKeyCode(keycode as Integer) as Integer

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Remote Control MBS ComputerControl Plugin 3.1 ✅ Yes ✅ Yes ❌ No ❌ No Desktop only
Returns the ASCII code which matches the key code with the current state.
Example
dim k as KeyCodesMBS

k=new KeyCodesMBS

MsgBox str(k.KeyCodeToAscii(&h0A))
MsgBox chr(k.KeyCodeToAsciiWithSecondKeyCode(0))

// gives â on a German Keyboard

On the first call of KeyCodeToAscii you get the ASCII char, but if you call KeyCodeToAsciiWithSecondKeyCode and the state property is not changed, you can get what the user gets if he presses several keys.
KeyCodeToAscii resets state to 0 before calling.
On Windows, KeyCodeToAscii and KeyCodeToAsciiWithSecondKeyCode are equal.

Note on a Mac:
Bit 0 to 6 are the keycode, bit 7 is 1 if key goes up and 0 if key goes down.
Bit 8 to 15 are modifier keys:

Constants for the modifier keys:
shiftKey 512 shift key down?
alphaLock 1024 alpha lock down?
optionKey 2048 option key down?
controlKey 4096 control key down?
rightShiftKey 8192 right shift key down?
rightOptionKey 16384 right Option key down?
rightControlKey 32768 right Control key down?

Not available in 64-bit.

KeyCodesMBS.TestForAsciiKeyDown(ascii as Integer) as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Remote Control MBS ComputerControl Plugin 2.8 ✅ Yes ✅ Yes ❌ No ❌ No Desktop only
Returns true if the key with the given ascii code is pressed.

KeyCodesMBS.TestForKeyDown(keycode as Integer) as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Remote Control MBS ComputerControl Plugin 2.8 ✅ Yes ✅ Yes ❌ No ❌ No Desktop only
Returns true if the key with the given key code is pressed.
Example
Dim k As New KeyCodesMBS

Const VK_SHIFT = &h10 // for Windows
If k.TestForKeyDown(VK_SHIFT) Then
MsgBox "shift"
Else
MsgBox "no shift"
End If

Some examples using this method:

KeyCodesMBS.Update

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Remote Control MBS ComputerControl Plugin 2.8 ✅ Yes ❌ No ❌ No ❌ No Desktop only
Updates the layout so it is the current one.

The items on this page are in the following plugins: MBS ComputerControl Plugin.


The biggest plugin in space...