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 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)
                yourtext = yourtext..key

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


  • edited February 2012 Posts: 78

    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") 
  • 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.