Exergist Posted April 9, 2018 Share Posted April 9, 2018 I'm working on a mod and I need to have Papyrus change states in response to a key press combination. So for example, when I press keys "A," "B," and "C" (and only when all 3 keys are down) I want to change to a different state. I'm staying away from IsKeyPressed to avoid issues with constant polling for updates, so I've been looking at OnKeyDown and OnKeyUp events. Though perhaps a combination of the two would work, with an OnKeyDown event associated with "A" subsequently triggering a RegisterForSingleUpdate(0.1) followed by checking if both "B" and "C" are also down at that instant. Any thoughts or suggestions? Thanks! Link to comment Share on other sites More sharing options...
cdcooley Posted April 10, 2018 Share Posted April 10, 2018 You do want to mix the two methods if you want maximum efficiency but you don't want to register for updates. If your situation makes sense for the user to press the keys in a particular order that's easiest and most efficient. In some of my mods you can hold modifier keys to alter the effect of an action key (i.e. hold down shift + alt while pressing Keypad 5 and you'll get a different behavior than if you just press Keypad 5). If you have that simple case you register the final key and then check for the two modifier keys with IsKeyPressed directly in the OnKeyDown event. If you want to allow the keys to be pressed in any order you register for all three keys and when any one is pressed do the checks with IsKeyPressed for the other two. The important complication is that you have to make sure that it won't hurt anything if more than one of those triggers at the same time (or very close to the same time) due to timing issues. Link to comment Share on other sites More sharing options...
Exergist Posted April 10, 2018 Author Share Posted April 10, 2018 Thanks for the detailed feedback! I'll try out some of your suggestions. Link to comment Share on other sites More sharing options...
Recommended Posts