Skip to content

Keyboard

Ravbug edited this page Jan 13, 2019 · 2 revisions

You can read or write to the keyboard using the keyboard object, or just by using the name of the key without anything in front of it.

You can emulate keys that don’t actually exist on your keyboard if you want. For example the multimedia keys, or the Excel key, etc.

Keyboard emulation will now trigger the auto-repeat you normally get when you hold down a key on a real keyboard. Although you can disable this if you want. To disable it, set: Keyboard.RepeatFakeKeys = False

Normally a keyboard will only repeat the most recent key that you pressed. GlovePIE will simulate that same behaviour by default. If you hate that feature, and wish you could move diagonally in Notepad by holding two keys at once, you can disable it like this:

Keyboard.RepeatMultipleFakeKeys = False

By default GlovePIE will use the same key repeat rate as your real keyboard. But you can tell GlovePIE to repeat keys at a different rate if you prefer:

Keyboard.RepeatRate = 10 Hz

It is measured in Hz (Hz just means times per second).

Like a real keyboard, keys don't start repeating until after a delay. After the delay it will start repeating. You can set the delay like this:

Keyboard.RepeatDelay = 0.4 seconds

A very cool feature is that you can now swallow keys. When you swallow keys, other programs will not be able to read them. Only GlovePIE will be able to read them.

For example:

A = swallow(Left)
D = swallow(Right)

This means that when you press the Left arrow key the game won't receive the left arrow key, but it will receive the A key. If you didn't use swallow, the game would receive both the real key (Left) and the fake key (A).

If you have multiple keyboards, you can only swallow the key on all keyboards, not on specific keyboards. If you swallow a key on all keyboards, it is impossible for GlovePIE to tell which keyboard it came from.

Keyboard emulation doesn’t work as well on Windows 9x, because it won’t work in DirectInput games on 9x.

Keys can be either true or false. True when they are down and false when they are up. Some keys (like Pause) only tell you when they are pressed but not released, so the computer assumes they are released soon after.

Unless you are using Windows 9x, the keyboard keys will be the actual physical keys, ignoring whatever keyboard layout you are using.

Keyboard values, for example the F1 key can be set or read in various ways:

Keyboard.F1
Key.F1
F1

There are also special ways of writing key combinations:

^C
Ctrl+C
Ctrl and C

Also most keys have multiple names, which include most of the abbreviations you see written on the keys, as well as the full names. So just the guess key names and you will be fine.

Special Keyboard Fields

You can read or set Keyboard.ScanCode or Keyboard.VK to get or set the scancode or the virtual key code of the key that is currently down. They will be 0 when no key is down.

You can read Keyboard.Row to find out the row of the key that is currently down. It returns -1 if no key is down, or if it has no well-defined position (like backslash).

You can read or set Keyboard.AnyKey to tell if any key is currently down.

Set Keyboard.RawInput to force GlovePIE to use RawInput instead of DirectInput for the keyboard.

Multiple Keyboards

You can read from multiple keyboards with GlovePIE, if you have Windows XP. You will probably need extra USB keyboards. Multiple keyboards are rare, and not especially useful. You can’t write to multiple keyboards, because I haven’t seen any programs other than mine that can tell which keyboard you used.

Just put a number after the word keyboard, like this:

midi.BassDrum1 = keyboard2.Enter

It uses RawInput instead of DirectInput for reading multiple keyboards, so sometimes you can get better or worse results just by changing one of your “keyboard”s to a “keyboard1” so that it uses RawInput instead. You only need to mention keyboard1 once in your script to force it to use RawInput. RawInput will conflict with some exclusive-mode DirectInput software.

You can tell how many keyboards there are with Keyboard.Count. You can tell whether a keyboard exists with Keyboard2.Exists.

Keys that can’t be used

F Lock

The (stupid bloody) F Lock key can’t be read or simulated. It doesn’t send information to the computer when pressed. It just changes what the other keys do.

My Documents

The My Documents key doesn’t seem to have a scan-code or an AppCommand, so it is not useable with GlovePIE.

Messenger

The Messenger key doesn’t seem to work with GlovePIE.

Sleep, LogOff, Power

The Sleep, LogOff and Power keys shouldn’t be used because they turn everything off. Which kind of makes responding to them pointless. But the Sleep key does actually work in GlovePIE.

Acer Laptop special keys

Most of the Acer Laptop special keys don’t work, or only work sometimes. Including the envelope, Saturn, P, and e special keys; the media keys (FB, FF, MediaStop, PlayPause, VOL-, VOL+); the increase/decrease brightness keys, and the ?, Fn+F2, Fn+F3, Fn+F4, Fn+F5, Fn+F6, and Fn+F7. On the other hand, the Mute key (Fn+F8) works, but only triggers for a short while once you release it. The other VolumeUp and VolumeDown keys work fine (Fn+Up, Fn+Down), unlike their VOL- and VOL+ equivalents.

Keys that sort of work

You can use the multimedia keys, and application keys, but they may not work as well as other keys. You can’t usually tell how long they are held down. You can’t tell how long the Pause key was held down either.

Unicode Characters

You can also simulate Unicode characters. This allows you to make typing programs for other languages, or to type special symbols or letters.

The possible values are the word “Unicode” followed by the four hexadecimal digits for that character. See www.unicode.org for tables. For example, to type the Greek letter alpha when the user presses the joystick button:

key.Unicode03B1 = joystick.button1

This may not work on all programs or on all operating systems. The TypeUnicode command also send a string of characters by the same method. Although those characters sent by TypeUnicode can currently only be Ansi characters since GlovePIE strings are still Ansi. But they will be sent via the same Unicode messages.

Number Keys

The main number keys, with the symbols above them (eg. 1!, 2@, 3#, 4$ ) are named: “one”, “two”, “three”, “four”, etc.

eg.

Key.One = Joystick.Button1

The other number keys, on the numeric keypad, are named NumPad1, NumPad2, NumPad3, NumPad4, etc.

Most other keys are named according to what they have written on them.

Top Row

Escape F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, F13, F14, F15, F16, F17, F18, F19, F20, F21, F22, F23, F24 PrintScreen, SysReq, Pause, Break, ScrollLock

NOTE: Pause should not be confused with the new Play and Pause keys for music players. This Pause is the original Pause key that has been on every keyboard since the beginning. The new Pause key is called MediaPause.

This Pause key (and coincidently also the MediaPause one) doesn’t usually tell you when it is released. Which means GlovePIE will guess.

SysReq and Break used to be separate keys. Then the Break key got moved onto NumLock. Then the Break key got moved again onto Pause. Then the SysReq got moved onto PrintScreen. But the computer still regards them as separate keys. Break is Ctrl+Pause and SysReq is Alt+PrintScreen.

Number Row

Console, One, Two, Three, Four, Five, Six, Seven, Eight, Nine, Zero, Minus, Equals, Backslash, Backspace

Qwerty Row Tab, Q, W, E, R, T, Y, U, I, O, P, LeftBracket, RightBracket, Backslash

Next Row

CapsLock, A, S, D, F, G, H, J, K, L, Semicolon, Apostrophe, Enter

Next Row

LeftShift, Z, X, C, V, B, N, M, Comma, Dot, Slash, RightShift

Space Bar Row

LeftCtrl, LeftWindows, LeftAlt, Space, RightAlt, RightWindows, AppMenu, RightCtrl

The AppMenu key is the pointless key with a picture of a menu that works like the right mouse button. Don’t assume keyboards have a RightWindows keys. New ones only have LeftWindows.

Cursor Pad

NOTE!!!! The End key is tricky because it is also part of the GlovePIE language. Using Key.End is probably least confusing.

Home, End, PageUp, PageDown, Insert, Delete Up, Down, Left, Right

Numeric Key Pad

NumLock, Divide, Multiply, NumPadMinus NumPad7, NumPad8, NumPad9, NumPadPlus NumPad4, NumPad5, NumPad6, NumPadPlus NumPad1, NumPad2, NumPad3, NumPadEnter NumPad0, NumPadDot, NumPadEnter

Stupid Bloody F-Lock Function Keys

Help, Undo, Redo, New, Open, Close, Reply, Forward, Send, Spell, Save, Print

These all work in GlovePIE, but they don’t tell you when they are released.

Multimedia Keys

The MyDocuments key doesn’t work!!! It doesn’t seem to have a scancode, or an AppCommand, so GlovePIE can’t detect it or trigger it, and doesn’t even list it. Messenger doesn’t seem to work either.

MyPictures, MyMusic, Mute, PlayPause, MediaStop, VolumeUp, VolumeDown, PrevTrack, NextTrack, MediaSelect,

Mail, WebHome, Messenger, Calculator, LogOff, Sleep

Note that the MyPictures, MyMusic, and LogOff keys can’t be read properly.

The PlayPause, MediaStop, PrevTrack, and NextTrack keys only work for the correct duration if you have XP and your script includes multiple keyboards, or enables RawInput. For example:

key.RawInput = true
debug = PlayPause

Will show correctly when the PlayPause key is released.

MyMusic is the same key as OfficeHome. Intellitype needs to be set up with the correct keyboard type to perform the correct action.

Acer laptop Euro and Dollar keys

If you have an Acer laptop, you can now use the Euro and Dollar keys (near the arrow keys). But they only work if you exit or disable the Launch Manager program.

eg.

ppjoy.digital0 = Euro
ppjoy.digital1 = Dollar

Emulating these new keys will not type a euro or dollar sign, although some games may allow them to be used as game keys. To type a dollar sign, use Unicode0024. To type a Euro sign, use Unicode20AC. This is not a new feature.

Unicode0024 = Wiimote.A
Unicode20AC = Wiimote.B`

Other Keys

Other keys can be specified by their names or by their hexadecimal scan codes, like this:

key.Scan5B

Left, Right or Don’t Care

Keys with Left or Right versions, like Shift or Control, can be specified like this:

LeftShift
RightShift
Shift

If you just say Shift it will respond to either Shift key.

Clone this wiki locally