Set InputField non-interactable without clearing text

I’m making a little interactive terminal, and I want to make the terminal non-interactable until you press “E” on it, then set it non-interactable again after you press escape. However, setting the Interactable property on the Canvas Group seems to erase the text inside an attached InputField. Is there any way to avoid this?

The escape key erases the text when you are typing in the input field. I haven’t found a workaround to this, but haven’t been messing with input fields lately.

The best thing I can think of off the top of my head is to change the key that you use, or save the text to a variable with every keystroke except for the escape key and then use OnEnable() to set the input field’s value to that variable.