xxjhxx2 0 Posted July 29, 2017 Hi guys, I am attempting to create a script that opens when a key is held and closes when a key is released. I have tried using the onKeyUp and onKeyDown handlers but the onKeyUp handler does not seem very responsive. Does anyone know if it is possible to do, or if using a mod would be a better option? If I could use a mod I would, could someone point me in the right direction? Thanks! Share this post Link to post Share on other sites
das attorney 858 Posted July 29, 2017 How far have you got with your script? Post it up and we can see better what you need to do. Share this post Link to post Share on other sites
soolie 189 Posted July 29, 2017 Are you creating a dialog or display with onkeydown? Share this post Link to post Share on other sites
xxjhxx2 0 Posted July 29, 2017 I will show you, i am running a file on key down that creates the dialog and i want it to close on keyup: //fn_keyDownHandler switch (_code) do { case 219: { if (!life_action_inUse) then { [] spawn { private "_handle"; _handle = [] spawn life_fnc_actionKeyHandler; waitUntil {scriptDone _handle}; life_action_inUse = false; }; }; }; }; //fn_keyUpHandler switch (_code) do { case _interactionKey: { if (!(_menu isEqualTo 10)) then { hint "I tried"; closeDialog 0; }; }; }; 1 hour ago, soolie said: Are you creating a dialog or display with onkeydown? 2 hours ago, das attorney said: How far have you got with your script? Post it up and we can see better what you need to do. Share this post Link to post Share on other sites
killzone_kid 1329 Posted July 29, 2017 When you hold down your key, EH will be fired continuously with the rate of key autorepeat. Bad idea to spawn anything from it unless you can limit it to one execution per key press Share this post Link to post Share on other sites
xxjhxx2 0 Posted July 29, 2017 Just now, killzone_kid said: When you hold down your key, EH will be fired continuously with the rate of key autorepeat. Bad idea to spawn anything from it unless you can limit it to one execution per key press Any ideas how to do it more efficiently, just run a file on a press and close the created dialog on release... Share this post Link to post Share on other sites
soolie 189 Posted July 29, 2017 Im guessing that the the keydown creates a dialog bc the keyup is supposed to close it. I think the problem is that you are adding the key up to dialog 46(main dialog), but your keydown is creating a dialog so the key up eh should be added to that display and not the main. Share this post Link to post Share on other sites
killzone_kid 1329 Posted July 29, 2017 Good point by soolie. Depends on how dialog is created. If it is created as display, then keyUp attached to display 46 will not fire, however if it is created as dialog, it fires ok Share this post Link to post Share on other sites
xxjhxx2 0 Posted July 29, 2017 1 hour ago, killzone_kid said: Good point by soolie. Depends on how dialog is created. If it is created as display, then keyUp attached to display 46 will not fire, however if it is created as dialog, it fires ok 1 hour ago, soolie said: Im guessing that the the keydown creates a dialog bc the keyup is supposed to close it. I think the problem is that you are adding the key up to dialog 46(main dialog), but your keydown is creating a dialog so the key up eh should be added to that display and not the main. It is created as a dialog and they are set as: (findDisplay 46) displayAddEventHandler ["KeyDown", "_this call life_fnc_keyHandler"]; (findDisplay 46) displayAddEventHandler ["KeyUp", "_this call life_fnc_keyUpHandler"]; Share this post Link to post Share on other sites