How to use ajax callback on auto complete field inside a block settings form?
To answer the title's question
  '#ajax' =&gt; [
    'callback' =&gt; '::my_ajax_callback',
    'wrapper' =&gt; 'my-specializations',
    'event' =&gt; 'change', // run ajax on change
    'keypress' =&gt; TRUE, // if set to TRUE, then the element's #ajax['event'] will be triggered if the ENTER key is pressed while the element has focus.
  ],