A few questions

In order of importance…

  1. How do I determine when the enter key is pressed on the keyboard?
  2. Is there any way to store a table in the LocalData or is it just single variables?
  3. Why doesn’t codea support 1 interchangeable with true and 0 interchangable with false?
  4. Does everyone else experience the same thing as I do with multi-line code? (The coloring gets messed up, usually just all black, and I sometimes see some of the same text in two spots)
  1. I think it generates a "
    " key event

  2. Only single variables, numbers and strings. I’d suggest using json to store tables (here’s a lib: http://www.chipmunkav.com/downloads/Json.lua)

  3. isn’t that just how lua works? Don’t think this is codea specific

  4. yes. TLL is aware but apparently hard to fix on their side. I think @Simeon mentioned somewhere the new iOS makes it easier to fix.

If you mean the return key on the iPad, then this works.

function keyboard(key)
    if key == RETURN then
        print("return key pressed")  
    end
end

I have added this page about RETURN to the wiki.

Thanks guys this was exactly what I was looking for. Especially the function keyboard(key), I was unaware that that existed :slight_smile:

Here is an ASCII chart showing the supported characters and their values. Also, you can press any key and get the character, decimal, and hex value for that key. Hope this helps anyone unfamiliar with the keyboard function.


-- Ascii chart and key values

supportedOrientations(PORTRAIT)

function setup()
    displayMode(FULLSCREEN)
    showKeyboard()
    cval="char ="
    dval="dec  ="
    hval="hex  ="
end

function draw()
    background(30,30,30)
    textMode(CORNER)
    text("ASCII CHART",200,950)
    text("PRESS ANY KEY",600,950)
    text(cval,600,900)
    text(dval,600,850)
    text(hval,600,800)
    z=0
    textMode(CENTER)
    for y=1,16 do
        for x=1,16 do
            xx=20+x*30
            yy=950-y*40
            fill(255,0,0)
            text(z,xx,yy)
            fill(0,255,0)
            text(string.char(z),xx,yy-20)
            z = z + 1
        end
    end
    
     -- re-show keyboard if hide keyboard key is pressed  
    if CurrentTouch.x > 650 and CurrentTouch.y < 100 then 
        showKeyboard()
    end
end

function keyboard(key)
    if string.byte(key) == nil then
        cval="nil"
        dval="nil"
        hval="nil"
        return
    end
        
    cval=string.format("char = %s",key)
    dval=string.format("dec  = %3d",string.byte(key))
    hval=string.format("hex  = %02X",string.byte(key))
end