{"name":"BIS_fnc_keyHold","title":"BIS fnc keyHold","type":"function","url":"https://community.bistudio.com/wiki/BIS_fnc_keyHold","revid":341362,"updated":"2023-05-24T12:59:06Z","groups":["Interaction"],"status":"ok","games":{"arma3":"1.00"},"since":"arma3 1.00","arma3_since":"1.00","locality":{"effect":"local"},"exec":"spawn","description":"Allows for hold button interactions. Hold action is started by pressing <kbd>Space</kbd>.","syntaxes":[{"syntax":"[description, duration, condition, arguments, loaded] spawn BIS_fnc_keyHold","params":[{"name":"description","type":"String","description":"description of the performed action, displayed inside the progress bar.","type_expr":"String"},{"name":"duration","type":"Number","optional":true,"default":"2","description":"action duration","type_expr":"Number","text":"duration: Number - (Optional, default 2) action duration"},{"name":"condition","type":"Code or String","optional":true,"default":"`{ true }`","description":"condition that must be met for the action to display","type_expr":"Code | String","text":"condition: Code or String - (Optional, default `{ true }`) condition that must be met for the action to display"},{"name":"arguments","type":"Array","optional":true,"default":"`[]`","description":"arguments passed to the condition","type_expr":"Array","text":"arguments: Array - (Optional, default `[]`) arguments passed to the condition"},{"name":"loaded","type":"Boolean","optional":true,"default":"false","description":"defines if function is already loaded. This is handled by the function","type_expr":"Boolean","text":"loaded: Boolean - (Optional, default false) defines if function is already loaded. This is handled by the function"}],"returns":{"types":["Script Handle"],"description":"- spawn: Script Handle - call: true if action was successful or false if it was interrupted.","text":"- spawn: Script Handle\n- call: true if action was successful or false if it was interrupted."}}],"examples":[{"code":["[\"Hold that key!\", 2, { alive player }] spawn BIS_fnc_keyHold;"]},{"text":"Function can be called in scheduled environment to return values and be used for further code execution.\n\n```sqf\n0 spawn {\n    private _success = [\"Hold that key!\", 2, { alive player }] call BIS_fnc_keyHold;\n    if (_success) then { hint \"Function executed\" } else { hint \"Function interrupted\" };\n};\n```","code":["0 spawn {\n\tprivate _success = [\"Hold that key!\", 2, { alive player }] call BIS_fnc_keyHold;\n\tif (_success) then { hint \"Function executed\" } else { hint \"Function interrupted\" };\n};"]}],"see_also":["BIS_fnc_holdActionAdd","BIS_fnc_holdKey"]}