Alright, Now I will do by best to answer. (My apologizes for the delay)
Can someone please explain the change for input event?
According to this tweet by Juan, the changes to InputEvent were to help simplify the code base.
Was trying to program a no key event so that my move_speed is reset to default when I double tap run. And yes I have tried !input.is_action_pressed(key) || and so on does not work but works in Unity tho
Here are three possible ways I would try, if it were me.
One way is to use the Input.is_action_pressed. Here's an example:
var is_left_down = false;
func _fixed_process(delta):
if (Input.is_action_pressed("LEFT")):
is_left_down = true;
else:
is_left_down = false;
if (is_left_down == true):
# Handle input here!
else:
# Handle lack of input here!
Not the 'cleanest' method out there, but it gets the job done, and is relatively simple to implement. A downside with this method is you have to store a boolean for every key you want to track. This can lead to code like this:
if (is_left_down == false and is_right_down == false and is_up_down == false and is_down_down == false):
# All of the movement keys are not pressed!
Which is kinda ugly.
The other way is using _input. I haven't actually used this, but it would look something like this:
var action_reference = {};
func _ready():
var actions = InputMap.get_actions();
# For every action, make a blank list
for action in actions:
action_reference[action] = [];
# Add every action's button's scancodes
for action in actions:
for action_event in InputMap.get_action_list(action):
if (action_event is InputEventKey):
action_reference[action].append(action_event.scancode);
set_process_input(true);
func _input(event):
if (event is InputEventKey):
var event_scancode = event.scancode;
var found = false;
for actions in action_reference:
for action_scancode in action_reference[actions]:
if (event_scancode == action_scancode):
found = true;
break;
if (found == false):
print ("A key was pressed, but not one assigned to a action!");
The biggest problem with this method, is that some key has to be pressed, so you cannot know if nothing is being pressed unless some other key is pressed.
---
The third way is tracking input as accurately as you can. I've tried this before settling on first method and I would say this method has it's flaws, but maybe it's just me. It looks like this:
var some_key_down = false;
var key_check_toggle = false;
func _ready():
set_process_input(true);
set_fixed_process(true);
func _fixed_process(delta):
if (key_check_toggle == true):
if (some_key_down == false):
print ("No keys pressed!");
else:
some_key_down = false;
print ("Some key(s) is pressed");
key_check_toggle = !key_check_toggle;
func _input(event):
if (event is InputEventKey):
some_key_down = true;
The biggest problem with this method is latency and inconsistent results. If you comment out the toggle check code in _fixed_process and watch the console, you see it jitters from pressed and not pressed. Adding the toggle fixes the jitter issue, but introduces latency, which can be seen when you hold down a key and watch the console output.
---
I would suggest using the first method. It is a little ugly, but it should be easier to maintain and use.
That said though, there is probably some way to make the second method work without needing to wait on a key press, I just don't know what it is. The third method is a little bit of a hack, has latency issues, and sometimes gives inconsistent results, but it might just need some more tweaking to make it work.