What can I do to prevent multiple events?

When the script first load, it will call functionA (This function removes li elements, add new li elements and attach event listener to li parent, which is ul ) , I also have a input calling this functionA on keyup, so my problem is, it will attach new event to ul every time when I call functionA (when I input value into my input field) . I can’t just move the part of the code where it adds event to ul out of the functionA, because inside of the addEventListener I am also calling another function which will take some data that is passed into functionA.
(Example code below)

What’s the “best way” to solve this problem, so that the “event won’t get added again and again to ul element” every time when functionA is called?

Example code:

const userList = document.querySelector(".user-list");
const pageList = document.querySelector(".page-list");
const inputEl = document.querySelector(".my-input");

const functionA = (userList /* This data need to pass into functionB */) => {
  const numberOfPages = Math.ceil(userList.length / 10);
  pageList.innerHTML = "";
  let newPageListHtml = "";
  for (let i = 1; i <= numberOfPages; i++) {
    newPageListHtml += `
        <button type="button">${i}</button>
  pageList.innerHTML = newPageListHtml;

    Add event listener to ul..

    I can't take this part of the code outside of this function because 
    functionB which is inside event listener needs "userList" data.
  pageList.addEventListener("click", (e) => {
    if (e.target.tagName === "BUTTON") {
      const clickedPageNum = Number.parseInt(e.target.textContent);
      /* functionB here */
      functionB(userList, clickedPageNum);

/* Run when script first load */

/* Run on input field keyup */
inputEl.addEventListener("keyup", (e)=>{
  /* codes... */
  const filteredUserList = [...userList.children].filter((userListChild)=>{
    /* codes... */
    return userListChild

   /* Call functionA, pass in new data  */
  functionA(filteredUserList );

Take a look here for options in attaching event listeners EventTarget.addEventListener() - Web APIs | MDN