I want to use the same key (in this case "Z") to be able to open a text box and also close it, even to continue to another dialog line. Is this possible?
Develop games in your browser. Powerful, performant & highly capable.
You can nest a lot of actions for the same key as sub-events. In terms of dialogue, I've put together a course of various ways to do it and some of them use the Z key to progress the dialogue.
It might be a bit complicated because it uses JSON, but that section of the tutorial course should have examples of using the Z key for dialogue. I think the Array-based tutorial uses it too, but I think it's a simpler use. Plus, most of those tutorials should have example files too.
Tutorial Course - Displaying Dialogue in Games