Custom Number Pad to Simulate Keyboard Press?

Godot Version

Godot 4.2

Question

I made a custom number pad for my game, and I just want each button to simulate a keyboard press of each number.

I was able to make it so that it changed the text of my LineEdit, however I was running into problems with other code that way. I would prefer to directly simulate a keypress if possible.

This is what I’ve tried, however it doesn’t seem to do anything even when my LineEdit has focus.

func _on_button_pressed():
var event = InputEventKey.new()
event.keycode = KEY_1
event.pressed = true
Input.parse_input_event(event)

Any help would be greatly appreciated!