Spoiler
if not commands then
error("Please use an command computer. If you use an older version of CC please use CC 1.7 or newer.")
end
local id=os.getComputerID()
local keynormal={"1","2","3","4","5","6","7","8","9","0","backspace","q","w","e","r","t","z","u","i","o","p","enter","capsLock","a","s","d","f","g","h","j","k","l","up","down","space","y","x","c","v","b","n","m","left","right","tab","rightCtrl"}
local capskey={"!",'\\"',"?","$","%","&","/","(",")","=","backspace","Q","W","E","R","T","Z","U","I","O","P","enter","capsLock","A","S","D","F","G","H","J","K","L","up","down","space","Y","X","C","V","B","N","M","left","right","tab","leftCtrl"}
local testcaps=false
local commandCheck=commands.exec('/trigger keyboard'..id..' set 0')
local function clearChat()
local _=""
for i=1,99 do
_=_.." "
end
commands.exec('tellraw @p "'.._..'"')
end
local function createKeyboard()
local text='/tellraw @p [""'
for i=1,#keynormal do
text=text..',{"text":"'
if testcaps then
text=text..capskey[i]
else
text=text..keynormal[i]
end
text=text..'","color":"blue","clickEvent":{"action":"run_command","value":"'..(commandCheck and ('/trigger keyboard'..id..' set '..i) or ('/scoreboard players set @p keyboard'..id..' '..i))..'"}},{"text":" "}'
if i==11 or i==23 or i==35 or i==46 then
text=text..']'
commands.exec(text)
text='/tellraw @p [""'
end
end
end
commands.exec("scoreboard objectives remove keyboard"..id)
if commandCheck then
commands.exec("scoreboard objectives add keyboard"..id.." trigger")
else
commands.exec("scoreboard objectives add keyboard"..id.." dummy")
end
commands.exec("gamerule sendCommandFeedback false")
commands.exec("gamerule commandBlockOutput false")
commands.exec("gamerule logAdminCommands false")
if commandCheck then
commands.exec("scoreboard players enable @p keyboard"..id)
end
clearChat()
createKeyboard()
local a=function()
while true do
if commands.exec("testfor @p[score_keyboard"..id.."_min=1]") then
local _success,_output=commands.exec("scoreboard players list @p")
if _success and #_output>1 then
for i=2,#_output do
if string.sub(_output[i],3,string.find(_output[i],":")-1)=="keyboard"..id then
local _=tonumber(string.sub(_output[i],string.find(_output[i],":")+2,string.find(_output[i],"%(")-2))
if type(_)=="number" and keynormal[_] then
if testcaps then
if #capskey[_]==1 then
os.queueEvent("key",keys[string.lower(capskey[_])])
else
os.queueEvent("key",keys[capskey[_]])
end
else
if #keynormal[_]==1 then
os.queueEvent("key",keys[string.lower(keynormal[_])])
else
os.queueEvent("key",keys[keynormal[_]])
end
end
if #keynormal[_]==1 then
if testcaps then
os.queueEvent("char",capskey[_])
else
os.queueEvent("char",keynormal[_])
end
elseif keynormal[_]=='\\"' then
os.queueEvent("char",'"')
elseif keynormal[_]=='space' then
os.queueEvent("char",' ')
end
oldcaps=testcaps
testcaps=(keynormal[_]=="capsLock" and not testcaps) or false
if testcaps~=oldcaps then
clearChat()
createKeyboard()
end
end
if commandCheck then
commands.exec("scoreboard players reset @p keyboard"..id)
commands.exec("scoreboard players enable @p keyboard"..id)
clearChat()
createKeyboard()
else
commands.exec("scoreboard players set @p keyboard"..id.." 0")
clearChat()
createKeyboard()
end
break
end
end
end
end
sleep(0)
end
end
local b=function()
if fs.exists("rom/programs/shell") then
local ok,err=pcall(loadfile("rom/programs/shell"))
else
local ok,err=pcall(loadfile("rom/programs/shell.lua"))
end
end
parallel.waitForAny(a,B)/>