AJAX listener on text_format field I am trying to activate an AJAX callback on every change by the user of a text_format field (which is part of a standard bundle edit form). The name of the field in the snippets below is field_reponse

The code works perfectly with other fields (dropdown, textfield), but not for the formatted text areas of type "text_format".

I suppose it is connected with the post-processing of CKEditor. Am I right ? In any case, is there a workaround?

    function MY_MODULE_form_node_shut2_edit_form_alter(&amp;$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id){

    // Autosave

    $form['field_reponse']['widget'][0]['#ajax'] = array(
            'callback' =&gt; 'Drupal\MY_MODULE\Form\FormAutosave::autosave',
            'event' =&gt; 'click',
            'wrapper' =&gt; 'autosave_ajax_placeholder',
            'progress' =&gt; array(
              'type' =&gt; 'throbber',
              'message' =&gt; NULL,
        ),
    );


  // Add placeholder for Ajax response markup
  $form['autosave_ajax_response'] = array(
            '#type' =&gt; 'html_tag',
            '#tag' =&gt; 'div',
            '#value' =&gt; t('Placeholder for ajax response'),
            '#attributes' =&gt; array(
              'class' =&gt; array('hidden'),
              'id' =&gt; array('autosave_ajax_placeholder'),
        ),
    );
    } 

    return $form;
}


The callback:

&lt;?php

namespace Drupal\MY_MODULE\Form;

use Drupal\Core\Form\FormStateInterface;
use Drupal\node\Entity\Node;

class FormAutosave {

  public static function autosave(array &amp;$form, FormStateInterface $form_state) {

    // Load the shut2 and get changed form element
    $node = $form_state-&gt;getFormObject()-&gt;getEntity();
    //$curr_values = $form_state-&gt;getValues();
    //$triggering_element = $form_state-&gt;getTriggeringElement();
    //drupal_set_message($triggering_element));
    // Set and save node with new value for field
    //$node-&gt;set($triggering_element, $triggering_element['#value']);
    $node-&gt;set('field_reponse', $form_state-&gt;getValue('field_reponse'));
    $node-&gt;save();

    // Add an Ajax response to avoid error 
    $response = [
      '#markup' =&gt; t('Sauvegardé automatiquement !'),
    ];
    return $response;

  }

}
I think the event should be keyup not click.