Page 1 of 1

Aliases to bind two actions to one key.

Posted: Thu Oct 01, 2015 10:31 pm
by Vincent(PDP)
I've made an alias which makes it possible to bind two actions to a single key/button and switching between them by holding down the specified modifier key.
I'm thinking that perhaps someone else than me will find it useful. :)

Code: Select all

alias +keymodifierdown "set x_keyboard_keymod 1"
alias -keymodifierdown "set x_keyboard_keymod 0"

alias keymodifier "test $x_keyboard_keymod %2 %1"
How it works:
1. Bind a key or button to use as a modifier key.
Example:

Code: Select all

bind k +keymodifierdown
2. Bind another key to be used as the multi-action key.

Code: Select all

STRUCTURE: keymodifier <command when not pressed> <command when pressed>

bind c "keymodifier sayhi wohoo"
Aliases used in example:

Code: Select all

alias sayhi "say Hi!"
alias wohoo "say WOHOO!; +jump; wait 1; -jump"
Now, when pressing the 'c' button on the keyboard, it will write "Hi!" to the chat.
And if I hold down the 'k' button and then press 'c' the player will jump and write "WOHOO!" to the chat.


Hope this is to any use! :)

RE: Aliases to bind two actions to one key.

Posted: Fri Oct 02, 2015 1:06 am
by Slim
Pretty cool there, before I read this I misinterpreted this as a toggle bind. My bad.

RE: Aliases to bind two actions to one key.

Posted: Fri Oct 02, 2015 7:39 am
by Vincent(PDP)
@Slim:
You can make it toggleable too if you want to.

Code: Select all

alias keymodifierset "set x_keyboard_keymod 1"
alias keymodifierunset "set x_keyboard_keymod 0"
alias keymodifierdown "test $x_keyboard_keymod keymodifierunset keymodifierset"

bind k keymodifierdown

RE: Aliases to bind two actions to one key.

Posted: Fri Oct 02, 2015 4:07 pm
by Klofkac
Vincent(PDP) wrote: @Slim:
You can make it toggleable too if you want to.

Code: Select all

alias keymodifierset "set x_keyboard_keymod 1"
alias keymodifierunset "set x_keyboard_keymod 0"
alias keymodifierdown "test $x_keyboard_keymod keymodifierunset keymodifierset"

bind k keymodifierdown
Sorry, his is redundant, command toggle x_keyboard_keymod is already working.
Well though, it is verbose...

RE: Aliases to bind two actions to one key.

Posted: Fri Oct 02, 2015 4:14 pm
by Ænima
I use something similar, I have an alias that rebinds mousewheelup to spynext and mousewheeldown to spyprev while R is held, and then you let go and mousewheel gets rebinded to weapon switching.