2

I have been trying to send keys (just as if you are typing on the keyboard) on overleaf using javascript and jquery. I can see there is a .ace_cursor object but it does not seem to work when I try to do this:

$('.ace_cursor').html('test')

Am I using the wrong object to dispatch keys or the wrong approach to do so?

I have also attempted jquery's trigger for all elements in the page. E.g.,

$('.ace_content').click(() => {
var e = jQuery.Event( 'keypress', { which: 65} );
$('*').each(function(i, obj) {
    $(this).trigger(e);
    console.log($(this));
});
})
Michael
  • 1,759
  • 4
  • 19
  • 29
  • Have you seen this: https://stackoverflow.com/questions/1468384/simulate-keypress-with-jquery – kmoser Nov 18 '20 at 04:00
  • Yes, but it doesn't work. Jquery requires an object to send keys too. I just cannot figure out what is the element that the keys are sent to in overleaf. – Michael Nov 19 '20 at 00:30
  • You're saying it doesn't work, but what code did you try that didn't work? – kmoser Nov 19 '20 at 05:05
  • I added jquery code as an example that does not work. I have triggered keys in every element in the page but nothing. Yet, there must be a way that those divs receive the keys. – Michael Nov 20 '20 at 17:52
  • you want to listen to key press on specific element? can u tell me where did you get overleaf from? – armin yahya Nov 23 '20 at 14:44
  • @Michael do you still wait this answer? – development-ninja Nov 24 '20 at 20:06
  • I should have posted that with the ace-editor you can just connect to it and edit. So no need for an answer on this. Thank you for asking. – Michael Nov 25 '20 at 22:00

0 Answers0