This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
ComputerCraftFan11's profile picture

Convert keycode to a letter/number

Started by ComputerCraftFan11, 06 April 2012 - 03:59 AM
ComputerCraftFan11 #1
Posted 06 April 2012 - 05:59 AM
How can I convert any keycode but 28 into the letter/number that has been pressed?


while true do
  local e,key = os.pullEvent( "key" )
  oldkey = key
end
So if I press "i", it will change 23 (keycode for "i") into i
(without changing "key")
FuzzyPurp #2
Posted 06 April 2012 - 06:24 AM
Use print("i")? :)/>/>
ComputerCraftFan11 #3
Posted 06 April 2012 - 06:29 AM
Use print("i")? :)/>/>

Nevermind, I added;
local a,char = os.pullEvent("char")
Hawk777 #4
Posted 06 April 2012 - 10:03 AM
Sure, use the char event instead of the key event if that's an option. Otherwise (e.g. if you want to use special keys), http://minecraftwiki.net/wiki/Key_Codes has a list of all the numeric key codes.
ComputerCraftFan11 #5
Posted 06 April 2012 - 06:25 PM
Sure, use the char event instead of the key event if that's an option. Otherwise (e.g. if you want to use special keys), http://minecraftwiki.net/wiki/Key_Codes has a list of all the numeric key codes.

I'm using char and key now, key for enter, char for printing