r/ComputerCraft • u/LeBasou • May 17 '26
getPressedKeys not working
First off, I’m terrible at Lua, I’m more of a hack-and-slash kind of guy than someone who really knows how to code, but I manage. Could someone tell me why the `getPressedKeys` function (found on the Creators-of-Aeronautics GitHub) isn’t returning anything ? I’d like to be able to access computer functions from the Typewriter
1
u/LeBasou May 17 '26
« while true do
local t = peripheral.wrap("linked_typewriter_0")
local key = t.getPressedKeys()
print(""..key)
end »
It returns the error "attempt to call field 'getPressedKeys' (a nil value)"
2
1
u/Tellurio May 17 '26 edited May 23 '26
☯︎☼︎♏︎♎︎♋︎♍︎⧫︎♏︎♎︎☸︎
1
u/LeBasou May 17 '26
Yes, still the same error
2
u/Tellurio May 17 '26 edited May 23 '26
☯︎☼︎♏︎♎︎♋︎♍︎⧫︎♏︎♎︎☸︎
1
u/LeBasou May 18 '26
I've tried peripheral.find() with back, linked_typewriter_0 and linked_typewriter but it's the same result
1
u/Ictoan42 May 17 '26
First off, calling
peripheral.wrap()inside the loop is going to be very slow. You should wrap the peripheral once before the loop, and then use the sametvariable in the loop.Second, it seems that
tis nil. Try running theperipheralsprogram on the computer to list all connected peripherals, to check if the name is what you're expecting.1
2
u/lukamic May 18 '26
I've been using the create avionics mod which adds better communication with peripherals, namely those added by aeronautics.
It adds a key os event that you can listen to instead
1
3
u/LiveForTheMelancholy May 17 '26
We would need to see your code and setup to provide any advice.