How do I simulate keyboard action

Get help using Construct 2

Post » Fri Nov 28, 2014 8:30 pm

Keyboard object has no actions. How do I simulate action of some combination?

I want to make automatic text saving to clipboard. If there is no way to just put text in clipboard ( discussed here ), then I want to try this trick:

1. User presses "Save to clipboard" button
2. System focuses on a hidden textbox
3. System simulates "Ctrl + A" combinaion
4. System simulates "Ctrl + C" combination
Done!

What do you think? If it possible to make?
B
39
S
17
G
6
Posts: 238
Reputation: 7,985

Post » Sat Nov 29, 2014 10:05 am

bump
B
39
S
17
G
6
Posts: 238
Reputation: 7,985

Post » Sat Nov 29, 2014 1:54 pm

Maybe you could use some javascript to do it.
B
50
S
16
G
9
Posts: 1,098
Reputation: 11,237

Post » Sat Nov 29, 2014 6:29 pm

Browsers don't seem to let you simulate key presses.

The simplest way to get text to the clipboard would be this js, but it still requires the user to press ctrl-c enter.
"window.prompt('Copy to clipboard: Ctrl+C, Enter', 'what');"

All other solutions I've tried aren't working or are IE only. One that I haven't tried is ZeroClipboard which uses flash to access the clipboard, but it still requires the user to click. Also since it uses flash it won't work on android/ios.
B
94
S
33
G
114
Posts: 5,359
Reputation: 73,779


Return to How do I....?

Who is online

Users browsing this forum: Congrats2u and 23 guests