Add a custom key/button
Hi there,
I need to add a custom action to the game that the player would be able to bind to a button of choice.
I know how to do it if it were a mod, but this should work for a map in the workshop, i.e. I cannot overwrite existing files (right?).
the alternative is that I "hard-code" it via console command, but it isn't ideal:
1) not customizable
2) could overwrite existing options
any idea?
EDIT:
related topics
post92071.html?hilit=custom%20binding#p92071 (UNSOLVED)
post69091.html?hilit=custom%20binding#p69091 (partially solved)
Alternatively, game_ui.
Kindly asking the player to do it themselves in this kind of manner is the only option I can think of that won't mess up any previously set custom bindings by the player.

I should recreate a full keyboard with all the possible bindings, without excluding that someone playing in a cave would be glad to use "f12" instead of the default "alt".
more: I have to do it for controllers as well.
I would rather use the method suggested in the second thread I linked...
spongylover123 wrote:
First, you need to make a cfg file. Those manage the custom key bindings (make a backup first).
Then, add your key binding
bind "SHIFT" "ent_fire logic_relay trigger".
Then in your map, map a logic_auto and add this output
OnMapSpawn - @command - exec yourconfigname
And when you reach the end of your map, add the trigger
OnTrigger - @command - exec config_default
Remember to do the last output, since steam cloud will upload your key bindings and it will be like that forever until you reset the config file
...but what if the player exit before being able to reset the config?
I'd go for this route if I can write a config that ADD parameters, without changing the existing ones.
Also, by publishing the map in the Workshop, would the config file be included?
I'll test all the stuff above, but maybe you already know better.
Good luck to finding a method that works for you. It would be interesting to know what you decide to do.
(Maybe you can explain what the effect is without spoiling too much?)
Yours is interesting too. another suitable one would be pressing attack1 and attack2 at the same time.
What do you think if I just use the "duck" button? you still crouch but also trigger the new action.
No problem while flying, just a little stutter when on ground.
the last one is easily achievable with logic_playerproxy, though I'd prefer "quick_ping"...
gallardo wrote:
What do you think if I just use the "duck" button? you still crouch but also trigger the new action.
No problem while flying, just a little stutter when on ground.
If you can do that without causing problems with normal ducking, then I'd say go for it.
I've played Felix's "Shadow of Time" and I think it works fine there.
Doing the same would be ok; not the most elegant solution, but good enough for me.
I'd prefer exploit the "quick_ping" button, but I dont know how yet.
Anyway, I was quite happy with your methond, until I discovered that you cannot "duck" after a jump...
Honestly I wanted to check your map back again, but I can't now, so I'm not sure it happesn there too.
that's a big issue for me 
@DaMaGepy
I'd like to avoid it. felix's method almost worked!
With a mod I might also be able to use custom scene files and bik videos as well which would be nice.
But mainly I'm asking because as said, you can't crouch during a jump or while falling, and I have more than 1 binding.
(I know it sounds better to use in the portal 1 engine, but I'd really like to have all the portal 2 related entities, plus the portal 2 style, physics engine, and models/textures).
I think it's better to keep it a map as much as possible, to be workshop compatible.
I'd go for a mod if it really adds something.
It just keeps saying "bind <key> [command] : attach a command to a key"
was there an update that changed this or something?