KotoShamisen Posted February 21, 2018 Share Posted February 21, 2018 I'm a noob in Papyrus and I'm trying to make so that when the player presses a key in the keyboard like X, Y or whatever, a function from my script is executed. I tried it several times using stuff like RegisterForKey, OnKeyDown, Input.IsKeyPressed, but none worked. I also searched on Google, topics on the forum and in the documentation, but I'm having no luck so far. Everything works fine but the input. I'm not sure, but i think it's because I'm trying to do it in a script that extends from Quest. Can someone give me an explanation or an example piece of code pls? thx in advance Link to comment Share on other sites More sharing options...
NexusComa Posted February 23, 2018 Share Posted February 23, 2018 Place down and activator then in your script use onactivate as the trigger.The keypress thing isn't going to work out (for a few reasons). Link to comment Share on other sites More sharing options...
Evangela Posted February 23, 2018 Share Posted February 23, 2018 Tested this with a quest script Event OnInit() RegisterForKey(45) ; X key EndEvent Event OnKeyUp(Int KeyCode, Float HoldTime) if KeyCode == 45 ; not necessary but out of habit debug.trace("KeyCode: " +KeyCode+ " Holdtime: " +HoldTime) endif EndEvent From my log: [02/23/2018 - 07:47:56AM] KeyCode: 45 Holdtime: 0.134000 [02/23/2018 - 07:48:02AM] You might be confusing key input with UI input... I think. Link to comment Share on other sites More sharing options...
candlepin Posted February 23, 2018 Share Posted February 23, 2018 (edited) Sorry for asking, but you have SKSE installed and working properly, right? RegisterForKey won't work without this. Edited February 23, 2018 by candlepin Link to comment Share on other sites More sharing options...
KotoShamisen Posted February 23, 2018 Author Share Posted February 23, 2018 (edited) Sorry for asking, but you have SKSE installed and working properly, right? RegisterForKey won't work without this.Lol, you just made me remember that I had overwritten the skse scripts with the vanilla ones from the rar file, thx dude I was never going to notice. Tested this with a quest script Event OnInit() RegisterForKey(45) ; X key EndEvent Event OnKeyUp(Int KeyCode, Float HoldTime) if KeyCode == 45 ; not necessary but out of habit debug.trace("KeyCode: " +KeyCode+ " Holdtime: " +HoldTime) endif EndEvent From my log: [02/23/2018 - 07:47:56AM] KeyCode: 45 Holdtime: 0.134000 [02/23/2018 - 07:48:02AM]You might be confusing key input with UI input... I think.Just realized that I had also mistyped the OnInit section. Thanks candlepin, Rasikko and NexusComa for the help and replies :smile: Edited February 24, 2018 by KotoShamisen Link to comment Share on other sites More sharing options...
candlepin Posted February 23, 2018 Share Posted February 23, 2018 Sorry for asking, but you have SKSE installed and working properly, right? RegisterForKey won't work without this.Lol, you just made me remember that I had overwritten the skse scripts with the vanilla ones from the rar file, thx dude I was never going to notice. Tested this with a quest script Event OnInit() RegisterForKey(45) ; X key EndEvent Event OnKeyUp(Int KeyCode, Float HoldTime) if KeyCode == 45 ; not necessary but out of habit debug.trace("KeyCode: " +KeyCode+ " Holdtime: " +HoldTime) endif EndEvent From my log: [02/23/2018 - 07:47:56AM] KeyCode: 45 Holdtime: 0.134000 [02/23/2018 - 07:48:02AM]You might be confusing key input with UI input... I think.Just realized that I had also mistyped the OnInit section. Thanks everyone for the help and replies! :smile: Glad I was able to help! Lord knows I've received more than my fair share of help here! Link to comment Share on other sites More sharing options...
Recommended Posts