How to Use Shortcuts?

Godot Version

4.2

Question

I can’t understand ShortCut with this documentation. I don’t know what to do or how to even set it up. This is what I have so far.

func _ready():
	DisplayServer.window_set_title(app_name + ' - ' + current_file)
	
	for i in ['New File', 'Open File', 'Save File', 'Save as File', 'Quit']:
		$FileMenu.get_popup().add_item(i)
	
	$FileMenu.get_popup().set_item_shortcut(4, set_shortcut(KEY_Q), true)
	
	for i in ['About', "How to Use"]:
		$HelpMenu.get_popup().add_item(i)
	
	$FileMenu.get_popup().id_pressed.connect(_on_item_pressed)
	$HelpMenu.get_popup().id_pressed.connect(_on_item_help_pressed)

func set_shortcut(key):
	var shortcut = Shortcut.new()
	var inputevent = InputEventKey.new()
	inputevent.keycode = key
	inputevent.ctrl_pressed = true
	shortcut.events # what
	return shortcut

What are you wanting to do with a shortcut? Essentially this code is setting Ctrl+Q to the 5th menu item, which is Quit.