0

how can i make the javascript function to work while using text editor

 var editor = $('#CKEditor1').ckeditorGet();

    editor.on("instanceReady", function () {
        this.document.on("keydown", function (event) {
            console.log(editor.checkDirty());
          if (event.data.key == 32)
                alert('space bar pressed');
        });
    });
  • Try this question, maybe it can help you: http://stackoverflow.com/questions/424407/handling-key-press-events-f1-f12-using-javascript-and-jquery-cross-browser – Tezekiel Jul 18 '16 at 09:51
  • but my requirement is different from this what i need i need a java script function which will play and pause the audio file when i am working with ckeditor that means while typing in ckeditor if user press any of the key from 112-123 any one key then the audio should be played and paused –  Jul 18 '16 at 09:58
  • by using any one key from F1-F12 while typing in ckeditor i need to play and pause the audio file which is above the ckeditor –  Jul 18 '16 at 10:10
  • i had edited the post and added my current working code which play and pause the audio while working with ck editor and which forwards,backwards,play and pause,volume increase and decrease when i run the application now i need to call the ckeditor javascript function in normal javascript function or normal javascript function in ck editor javascript function such that it performs all the functions using keyboard they are forward,backward,play,pause,volume increase,decrease,fast forward and fast backward how can i do this can anyone please help me out its urgent requirement –  Jul 18 '16 at 17:11

1 Answers1

0

Try:

 $("#CKEditor1").keydown(function(event){
    if ( event.which == 112 ) {
     event.preventDefault();
     alert('F1 is pressed');
    }
 });
Daniel O Mensah
  • 396
  • 3
  • 9
  • 20
  • @abc have you at least tried this code and see if it works? – Daniel O Mensah Jul 18 '16 at 10:15
  • I think that it doesn't listen to the onkeydown. I've run out of suggestions but you might need to turn on the allow content by going to the "Advanced Options" section of your CKEditor profile and adding the following string into the text area: config.allowedContent = true; if even this does not help then you will have to look through the documentation http://docs.ckeditor.com/ – Daniel O Mensah Jul 18 '16 at 10:23