UDN
Search public documentation:
KeyBinds
日本語訳
中国翻译
한국어
Interested in the Unreal Engine?
Visit the Unreal Technology site.
Looking for jobs and company info?
Check out the Epic games site.
Questions about support via UDN?
Contact the UDN Staff
中国翻译
한국어
Interested in the Unreal Engine?
Visit the Unreal Technology site.
Looking for jobs and company info?
Check out the Epic games site.
Questions about support via UDN?
Contact the UDN Staff
UE3 Home > Input & Output Home > Key Binds
Key Binds
Overview
Key binding in Unreal Engine 3 is very flexible, and is mostly defined in the configuration file. It is works with Unrealscript, but it also has a very handy features to make things easier.
Definition
Key binds are defined within several properties.
- Name - Name of the key bind. This can either be an alias or a mapped key.
- Command - Command to execute when this key bind is activated.
- Control - Control needs to be held down for this key bind to activate.
- Shift - Shift needs to be held down for this key bind to activate.
- Alt - Alt needs to be held down for this key bind to activate.
- bIgnoreCtrl - If control is being held down, then this key bind is ignored.
- bIgnoreShift - If shift is being held down, then this key bind is ignored.
- bIgnoreAlt - If alt is being held down, then this key bind is ignored.
Key bind aliasing
Key binds are aliased when the Name doesn't match any mapped keys. Aliased key binds can then be used as a command. This was designed so that multiple keys could map to an alias (or multiple aliases). This is especially useful when the alias's command is reasonably complex or is duplicated often. In this aliased key bind, the key bind controls how ducking / crouching is performed. The alias is called GBA_Duck, and when activated it will call Duck and set the input variable aUp to -1.0 with an absolute axis to 100. When the alias is deactivated it will call UnDuck and set the input variable aUp to -1.0 with an absolute axis of 100.
Bindings=(Name="GBA_Duck",Command="Duck | onrelease UnDuck | Axis aUp Speed=-1.0 AbsoluteAxis=100")
Bindings=(Name="C",Command="GBA_Duck") Bindings=(Name="XboxTypeS_A",Command="GBA_Duck")
Key bind chaining
Key binds defined in the configuration file can be chained to execute several commands. The pipe separator allows you to chain several exec functions together, thus binding all of these exec function to the same key.
Bindings=(Name="BackSpace",Command="TurnAround | SwitchToRocketLauncher | StartFire")
Bindings=(Name="LeftMouseButton",Command="StartFire | onrelease StopFire")
Key bind onrelease modifier
The onrelease modifier allows the key bind to only activate the following command when the key / button is released.
Key bind variables
Axis
The axis modifier sets a float variable usually within the range of -1.f and 1.f. The main exception to this range rule is if the analogue device is a mouse. They are best used for analogue style controls such as a joy stick. This variable should be defined in either Controller, Input or any of their subclasses such as PlayerController or PlayerInput. The variable should be defined as:var input float aMouseX; // Where aMouseX is the name of the axis
Bindings=(Name="MouseX",Command="Axis aMouseX")
- AbsoluteAxis - This is a preprocessor to scale the input value by this multiplier over delta time. Defined as an integer.
- DeadZone - If the absolute difference on the input has not changed by a least this value, then input is ignored.
- Invert - This is a preprocessor to invert the input value by this amount.
- Speed - This is the speed at which this axis is changed by.
Button
The button modifier sets a byte variable to either 0 or 1 depending on the keys status. This variable should be defined in either Controller, Input or any of their subclasses such as PlayerController or PlayerInput. The variable should be defined as:var input byte bAltFire; // Where bAltFire is the name of the button
Bindings=(Name="RightMouseButton",Command="Button bAltFire")
Count
This is mostly used for analogue style controls as it counts the number of samples gathered from this control and sets a byte variable to this value. The variable should be defined as:var input byte bXAxis; // Where bXAxis is the name of the sample count
Bindings=(Name="MouseX",Command="Count bXAxis")
Toggle
This allows to automatically create a toggle using a byte as the target variable. The variable should be defined as:var input byte bLook; // Where bLook is the name of the variable
Bindings=(Name="L",Command="Toggle bLook")
Key bind toggle trick
You can use key binds to set new key binds. Because of this, you can create a simple toggle using just key binds. When V is first pressed, it will execute SwitchToWireframe which sets the key bind to SwitchToLit. Then when V is pressed, it will execute SwitchToLit which sets the key bind back to SwitchToWireframe. This creates a toggle-able key.
Bindings=(Name="SwitchToWireframe",Command="viewmode wireframe | SetBind V SwitchToLit") Bindings=(Name="SwitchToLit",Command="viewmode lit | SetBind V SwitchToWireframe") Bindings=(Name="V",Command="SwitchToWireframe")
Key binding to Unrealscript functions
These are called exec functions. Simply put, this system allows you to map functions written in Unrealscript directly to a key. A simple exec function sample involves putting an exec function in your custom player controller.
exec function MyCustomExecFunction(int ParameterA) { `Log("User executed my custom exec function with "$ParameterA); }
Bindings=(Name="K",Command="MyCustomExecFunction")
How to set key binds in Unrealscript
You can dynamically create or reset key binds at run time within Unreal Engine 3. There are three functions inside Input that facilitate this feature.
- GetBind(const out Name Key) - This returns a string which is the command that is currently bound to this key.
- SetBind(const out name BindName, string Command) - This sets a key to the new command and saves it to the config.
local PlayerController PlayerController; local WorldInfo WorldInfo; WorldInfo = class'WorldInfo'.static.GetWorldInfo(); if (WorldInfo != None) { PlayerController = WorldInfo.GetALocalPlayerController(); if (PlayerController != None && PlayerController.PlayerInput != None) { // You now have access to the input object instance for the local player controller PlayerController.PlayerInput.SetBind('J', "MyCustomExecFunction 1"); } }
Mappable keys
Here is a list of the keys that are mapped to Unreal Engine 3.
Keyboard
Function keys
- F1 - Function one.
- F2 - Function two.
- F3 - Function three.
- F4 - Function four.
- F5 - Function five.
- F6 - Function six.
- F7 - Function seven.
- F8 - Function eight.
- F9 - Function nine.
- F10 - Function ten.
- F11 - Function eleven.
- F12 - Function twelve.
Alphanumerical keys
- A - Letter A.
- B - Letter B.
- C - Letter C.
- D - Letter D.
- E - Letter E.
- F - Letter F.
- G - Letter G.
- H - Letter H.
- I - Letter I.
- J - Letter J.
- K - Letter K.
- L - Letter L.
- M - Letter M.
- N - Letter N.
- O - Letter O.
- P - Letter P.
- Q - Letter Q.
- R - Letter R.
- S - Letter S.
- T - Letter T.
- U - Letter U.
- V - Letter V.
- W - Letter W.
- X - Letter X.
- Y - Letter Y.
- Z - Letter Z.
Special keys
- Escape - Escape.
- Tab - Tab.
- Tilde - ~.
- ScrollLock - Scroll lock.
- Pause - Pause.
- one - One.
- two - Two.
- three - Three.
- four - Four.
- five - Five.
- six - Six.
- seven - Seven.
- eight - Eight.
- nine - Nine.
- zero - Zero.
- Underscore - _.
- Equals - =.
- Backslash - \.
- LeftBracket - [.
- RightBracket - ].
- Enter - Enter or Numpad enter.
- CapsLock - Caps lock.
- Semicolon - ;.
- Quote - '.
- LeftShift - Left shift.
- Comma - ,.
- Period - ..
- Slash - /.
- RightShift - Right Shift
- LeftControl - Left control.
- LeftAlt - Left alt.
- SpaceBar - Space bar.
- RightAlt - Right alt.
- RightControl - Right control.
- Left - Left.
- Up - Up.
- Down - Down.
- Right - Right.
- Home - Home.
- End - End.
- Insert - Insert.
- PageUp - Page up.
- Delete - Delete.
- PageDown - Page down.
- NumLock - Num lock.
- Divide - Numpad /.
- Multiply - Numpad *.
- Subtract - Numpad -.
- Add - Numpad +.
- PageDown - Page down.
- NumPadOne - Numpad one.
- NumPadTwo - Numpad two.
- NumPadThree - Numpad three.
- NumPadFour - Numpad four.
- NumPadFive - Numpad five.
- NumPadSix - Numpad six.
- NumPadSeven - Numpad seven.
- NumPadEight - Numpad eight.
- NumPadNine - Numpad nine.
- NumPadZero - Numpad zero.
- Decimal - Numpad decimal.
Mouse
- LeftMouseButton - Left mouse button.
- RightMouseButton - Right mouse button.
- ThumbMouseButton - Primary mouse thumb button.
- ThumbMouseButton2 - Secondary mouse thumb button.
- MouseScrollUp - Mouse wheel scrolling up.
- MouseScrollDown - Mouse wheel scrolling down.
- MouseX - Mouse movement on the X axis.
- MouseY - Mouse movement on the Y axis.
XBox360 Controller
- XboxTypeS_LeftThumbStick - Left thumb stick when pressed as a button.
- XboxTypeS_RightThumbStick - Right thumb stick when pressed as a button.
- XboxTypeS_DPad_Up - Directional pad up.
- XboxTypeS_DPad_Left - Directional pad left.
- XboxTypeS_DPad_Right - Directional pad right.
- XboxTypeS_DPad_Down - Directional pad down.
- XboxTypeS_Back - Back button.
- XboxTypeS_Start - Start button.
- XboxTypeS_Y - Y button.
- XboxTypeS_X - X button.
- XboxTypeS_B - B button.
- XboxTypeS_A - A button.
- XboxTypeS_LeftShoulder - Left shoulder button.
- XboxTypeS_RightShoulder - Right shoulder button.
- XboxTypeS_LeftTrigger - Left trigger when pressed as a button.
- XboxTypeS_RightTrigger - Right trigger when pressed as a button.
- XboxTypeS_LeftTriggerAxis - Left trigger when semi depressed.
- XboxTypeS_RightTriggerAxis - Right trigger when semi depressed.
- XboxTypeS_LeftX - Left thumb stick horizontal position when used as an analogue control.
- XboxTypeS_LeftY - Left thumb stick vertical position when used as an analogue control.
- XboxTypeS_RightX - Right thumb stick horizontal position when used as an analogue control.
- XboxTypeS_RightY - Right thumb stick vertical position when used as an analogue control.