Jump to content
Sign in to follow this  
xJordannx

Disable keys for custom ingame keybinds

Recommended Posts

Hi, I was wondering if it was possible to disable a key's function, for example, if you press 1 on the numpad it will look to the left, but I have changed it so that when someone presses it, it says a sound, but it also looks to the left.

So for this example I'd want to remove it looking to the left.

Share this post


Link to post
Share on other sites

I modified a script that was posted a while back so I could block several keys easily

call with this, just include the key your trying to block

for left it would be just

null=[["LookLeft"]] execvm "disable.sqf";

for more keys

null=[["LookLeft","LookRight"]] execvm "disable.sqf";

to cancel I just use

 keybindings = [];

list of key codes

http://community.bistudio.com/wiki/ArmA_2:_CfgDefaultKeysMapping

save as disable.sqf

// list of keys you can use
//http://community.bistudio.com/wiki/ArmA_2:_CfgDefaultKeysMapping
//
// Example the folowing keys should now not work
// null=[["Prone","Stand","reloadMagazine","getOver"]] execvm "disable.sqf";
//

if (isNull player) exitwith {} ;
_boundkeys = _this select 0;

keybindings = [];
{ keybindings = keybindings + [(actionKeys _x) select 0] } foreach _boundkeys;

dokeyDown={
    private ["_r"] ;
    _r = false ; 
   if ((_this select 1) in keybindings) then {
       // place your code here
       hint "down";
        _r = true;
     };
    _r;
} ;

dokeyUp={
    private ["_r"] ;
    _r = false ;
    if ((_this select 1) in keybindings) then {
        // place your code here
          hint "up";
          _r = true;
     };
    _r ;
} ;


//I don't know why a delay is necessary :-(
sleep 0.5;


(FindDisplay 46) DisplaySetEventHandler [
    "keydown",
    "_this call dokeyDown"
    ];

(FindDisplay 46) DisplaySetEventHandler [
    "keyup",
    "_this call dokeyUp"
    ];  

Probably not the best way of doing it but it does work for me.

Edited by F2k Sel

Share this post


Link to post
Share on other sites
Return true from the onKeyDown handler.

Could you explain how to do that?

Thanks.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×