Getting search term

Basically my question is equal to this github issue
I need a way to get the current term in the search input.

My use case that on dropdown click - user redirected to one resource, but if user clicks enter he redirects to another resource within as search term,
My code is something like:

      placeholder: 'Type name or term',
      minimumInputLength: 2,
      maximumSelectionLength: 1,
      formatResult: formatPerson,
      formatSelection: formatPersonSelection
    }).on('change keypress', function (e) {
      console.log(e); // did not found search term here
      if (window.event.keyCode === 13) {

        //console.log($(this).val()); // did not found search term here

        select2 = $('.js-example-data-ajax').data('select2');
        searchedInput =;
        console.log(searchedInput); // did not found search term here

         $(location).prop('href', '' + searchTerm(?) + ');
       $(location).prop('href', '/human/' + e.added.humanId);

Also it seems my select2 version is quite outdated but there is no way I can upgrade it at moment.
I would appreciate any ideas. :pensive: