Table of Contents
autoloads / keyboard_handler / keyboard_handler.tscn
Diagram
Overridden virtual functions
_input
func _input(event):
handle_mouse_visiblity(event)
if Input.is_action_just_pressed("toggle_fullscreen"):
toggle_fullscreen()
Instantiators
|
Caution
|
No other scene instantiate this scene. |
Scene Tree
-
KeyboardHandler Node
Signal Connections
|
Note
|
No signal connections. |
Properties
| Name | Value |
|---|---|
script |
keyboard_handler.gd
extends Node
#class_name KeyboardHandler # defined in autoloads
func _input(event):
handle_mouse_visiblity(event)
if Input.is_action_just_pressed("toggle_fullscreen"):
toggle_fullscreen()
func handle_mouse_visiblity(event) -> void:
if event is InputEventMouse or event is InputEventKey:
change_mouse_visible(true)
elif event is InputEventJoypadMotion or event is InputEventJoypadButton:
change_mouse_visible(false)
func change_mouse_visible(val: bool) -> void:
if val:
Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
else:
Input.set_mouse_mode(Input.MOUSE_MODE_HIDDEN)
func toggle_fullscreen() -> void:
if DisplayServer.window_get_mode() == DisplayServer.WindowMode.WINDOW_MODE_FULLSCREEN:
DisplayServer.window_set_mode(DisplayServer.WindowMode.WINDOW_MODE_WINDOWED)
else:
DisplayServer.window_set_mode(DisplayServer.WindowMode.WINDOW_MODE_FULLSCREEN)