Problem handling text input in Godot 4.x with LineEdit

I am developing an application in Godot 4.x where I need to enter text into a LineEdit and process it when Enter or Tab is pressed. I’ve tried hooking up the text_submitted signal but it doesn’t seem to be working as expected. Here is my current code:

"
extends Node2D

@onready var input_field = $InputField
var word_list =

func _ready():
input_field.connect(“text_submitted”, self, “_on_text_submitted”)

func _on_text_submitted(new_text):
var text = new_text.strip_edges()
if Input.is_key_pressed(KEY_ENTER):
word_list.append(text)
_update_word_display()
input_field.clear()

func _update_word_display():
# Code to update the display of words

func _on_button_pressed():
# code to manage button
"

I use Godot 4.x and have verified that my scene has a LineEdit called InputField.
There are no error messages in the Godot console, but pressing Enter does not add the word to word_list.
I’ve tried adjusting the logic inside _on_text_submitted to handle KEY_TAB and KEY_ENTER as per the Godot documentation, but it still doesn’t work correctly.
I appreciate any suggestions or corrections you can offer. Thank you!