How to make 2 different actions for the same input?

Hello, I am developing the following action: running motion while the button “B” player is pressed. And run the motion scrolling while the same “B” button is just pressed without being kept. The error occurs when you hold “B” pressed and the player performs the action to run normally, but when releasing the button it automatically runs the animation scrolling. Example of games DarkSouls and Bloodborne where the same button performs different actions. I thank the attention and help.

Easiest way is to use a “count” variable, and the GetKeyDown and GetKey actions.

GetKey, is your “while held down” action, and GetKeyDown, only occurs once, at the time the key is pressed down, but not held.

For example (C#):

int count = 0;
count++; //add 1 to count every time the button is pressed - so if they hold down the key, count will be 1 regardless, and we can use a if-statement in the GetKey event, to make sure either GetKeyDowns action or GetKeys action is ever performed
//perform single-press action

//perform secondary action

count = 0; //reset count every time the button is released

Thanks for the great help, I managed to adapt and deploy the code with great success in my project.