DirectX Scancodes And How To Use Them
This is a short tutorial outlining, listing, and describing DirectX Scancodes and their function in mods. In this tutorial, I'll provide a few examples with which you can hopefully make use of with your mod, and try to shed light on what exactly they're used to accomplish.
What exactly are they?
DirectX Scancodes are input and registered into the game as integers whenever the corresponding key is pressed. That means that whenever you press a key, your computer registers the key's scancode as activated, so to speak. For example, pressing spacebar returns as scancode number 57, left mouse button as 256, etc.
What can they be used for?
The utility OBSE makes it possible for conditional statements to rely upon usage of DirectX scancodes in scripts. This makes it possible to make certain keys perform functions that they would not otherwise be capable of doing. By these means, you can do just about anything by just pressing a key, making way for new dynamic ways to improve combat, UI, and just about everything in-between.
How, exactly, do you use them?
These scancodes can be made use of by the conditional functions IsKeyPressed2, IsKeyPressed3, and OnKeyDown, with varying results.
IsKeyPressed2 is used with the basic function of detecting when the key is pressed, as well as detecting the functions "Tapkey" and "TapControl", which, when called from a script trigger a "false key press".
IsKeyPressed3 provides the same function as IsKeyPressed2, without registering Tapkey or Tapcontrol.
OnKeyDown returns as a boolean number if the specified key is pressed. For example, if I called "OnKeyDown 256", it would return as 1 when I clicked the left mouse key.
There you have it.
DirectX Scancode List
NOTE The list will, for now, be incomplete. When I find time, I will be sure to fill in the scancodes missing from the list.
Duplicate Equipped Weapon
- set weapon to player.getequippedobject 16 ;This detects in the game what your equipped weapon is
- if IsKeyPressed2 28 ;Script executes if you press enter
- player.additem weapon 1 ;Your weapon was successfully duplicated
- endif ;Always remember this for ending conditional statements
- set KeyPress to OnKeyDown 20 ;So, when you press T it returns as 1.
- if KeyPress == 1 ;Meaning, if you press T.
- Con_ToggleMenus ;Turns menus on/off.