Closed zz85 closed 9 years ago
@zz85 OMG THE LOCALSTORAGE THING IS SO COOL!!!! also me and @feross are still trying to figure out how to synth the keypress events....
@maxogden it's possible keypress vs keydown is the issue https://github.com/timoxley/keycode/wiki/wtf%3F-keydown,-keyup-vs-keypress
Actually, probably not. no.
Now I'm thinking, it's probably just that the <input>
doesn't listen for keyboard events and respond appropriately, because it's usually the element that's actually generating the events? Maybe?
looks like it was something like that: http://stackoverflow.com/a/4176116/62851
@maxogden Got it: https://github.com/eventualbuddha/keysim.js Buffer up the keys on the remote, then:
keyboard.dispatchEventsForInput(remoteKeys, document.currentElement);
thanks for the lead @timoxley :) are @maxogden @feross on the flight out or enjoying the :cat: cafe?
hmm. looks like keysim sends on key events (useful for checking key handlers) but doesn't change input values.
Note that none of the methods provided by keysim will trigger the browser's default behavior, such as inserting text or moving the cursor. It only allows you to test your event handling code by sending the correct DOM events.
something which would works would be more similar to the approach in http://bililite.com/blog/2011/01/23/improved-sendkeys/ (somehow I just remembered doing something similar ages ago)
got some crude form of keypresses to work... however to handle text selection, might need https://github.com/component/textarea-caret-position or https://github.com/mizzao/meteor-autocomplete
but this is starting to look like it might require all the hackery it takes to build codemirror.
i got bored on the plane and wrote https://github.com/maxogden/screenshare/blob/master/synthkeys.js, but it sucks that reimplementing browser behavior in js seems to be the only way to do it
@maxogden looks good. to support emoji / unicode characters, try the codemirror approach - use an invisible input field to capture characters and send it across to the actual textfield. hope you've reached safely :)
the references in codemirror
:)