Hello, This is the code that is used to delete an Item from inventory slot, but when I tried to do it with a key press (K) it does not work. How to fix this?
func _ready():
var slots = get_node("Panel/ScrollContainer/GridContainer");
for _i in range(MAX_SLOTS):
var slot = ItemSlotClass.new();
slot.gui_input.connect(self.slot_gui_input.bind(slot));
func slot_gui_input(event : InputEvent, slot : ItemSlotClass):
#WORK FOR MOUSE
if event is InputEventMouseButton:
if event.button_index == MOUSE_BUTTON_RIGHT:
if slot.item:
print("aaa")
#BUT DOES NOT WORK WITH KEYBOARD
if event is InputEventKey and event.pressed:
if event.keycode == KEY_K:
print("bbb")
if slot.item:
print("bbb")
I'm using keyboard to move and when Item is in focused I pressed K but It does not print "bbb" , also no errors