Anyway to emulate a keyboard press?

I’m trying to find a way to load clipboard into a project. string.byte() on a cmd+v press (paste) shows 102. Is there anyway to pass a keypress via code to act like the keyboard had pressed the key?

Actually not sure my idea will work. I basically want to find a way to emulate a cmd+v keypress to paste into keyboardbuffer()

I don’t think that will work, I’ve tried to use the clipboard but without luck

Yup, I’m afraid you are right.

I wanted to make a text selection tool but I thought what’s the use I can’t do anything with it

You could use parameter.text()'s text field to copy and paste… Or make a private clipboard exclusive to your project to store text in… Or a custom web page. I know when you create a bitly link you can press a button and it copies it… Maybe you could make an HTML script to http.request() to that can save text to the clipboard from headers (or the URL, i.e. http://www.example.com/copy.html?data=Message), or return text in the clipboard as the first parameter in the success function for http.request().

Actually, I know you have a server, could you make a script to do that? It would be very helpful. And I think possible.

@SkyTheCoder great ideas but I don’t think it will help my current dilemma. I need to get whatever the user copies from a webpage into codea, without keyboard use.

@Briarfox, I think that the 102 you are getting is from the first letter of what you have in the clipboard

@Briarfox I don’t quite get why that wouldn’t work… The user could long press on text, select copy and the iPad puts it on their clipboard. Then in your project you could do something like this:

function setup()
    print("Getting clipboard text...")
    http.request("http://www.example.com/clipboardGet.php", function(text, status)
        if status == 200 then
            print("Clipboard text: " .. text)
        else
            print("Error: invalid status, expected 200, got " .. status)
        end
    end, function(error)
        print("Error: " .. error)
    end)
end

(Pseudo-code, not made in a project, and would require valid host.)

Then you would just have to make http://www.example.com/clipboardGet.php, which would have access to the clipboard, return the text.

(Using the iPad’s built-in clipboard, i.e. the one in Safari.)

I think what @Briarfox was trying to say is: Is it possible to emulate the command that pastes into the keyboardBuffer when you hit cmd-v.

I dont think this is possible because i think that it is handled by iOS and not by Codea. But correct me if i’m wrong.