Decimal and hyphen from onscreen keyboard vs. numpad

Yes the keypad keys are a different scan code. But that isn’t in play here.
Neither of your functions are actually going to work. I don’t think you completely tested them.
The first function _is_valid_number() doesn’t match the keyboard numbers. It does find the “-” and the “.” but 0 -9 from either keyboard or keypad doesn’t match.
The second function breaks down if character length > 1. How would you match -1?
If you send one character at a time it will return true on 1-
Is there any reason to not use the String classes built in is_valid_float() function?

@onready var line_edit: LineEdit = $LineEdit
var old_text:String = ""

func _on_line_edit_text_changed(new_text: String) -> void:
	if new_text.is_valid_float(): 
		old_text = new_text
		line_edit.text = old_text

If the ‘e’ is not welcome then try this guys regex.