Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Keyboard backspace

edited February 2012 in Examples Posts: 622

I found this http://twolivesleft.com/Codea/Talk/discussion/comment/5706 really helpful in figuring out how to get backspace to work with showkeyboard()

snippet below

function keyboard(key)
        if key ~= nil then
            if string.byte(key) == 10 then
                --do something with "return" key
            elseif string.byte(key) == nil then --must be a backspace
                if string.len(yourtext) > 0 then
                    yourtext = string.sub(yourtext, 1, string.len(yourtext) - 1)
                end
            else
                yourtext = yourtext..key
            end
        end
end

(this is to make it easier to search for in this forum)

Comments

  • edited February 2012 Posts: 76

    From the reference, I think you can determine whether the pressed key is BACKSPACE key or not by comparing the key with constant BACKSPACE as follows

    if key==BACKSPACE then
      print("press Backspace") 
    end 
    
  • Posts: 2,820

    Thanks! This will be helpful in the future!

  • Ah, I must have scrolled right past that.

Sign In or Register to comment.