Termux has some "soft keys" for ESC, ctrl, alt etc (user-definable). Swipe in from left, hold the button labeled "keyboard".
Hacker's Keyboard (app) is the recommended onscreen keyboard (has ESC etc).
But really need a bluetooth keyboard e.g. logitech K480 or fullsize logitech K375s - or regular USB one if your phone has OTG. Bonus: doubles screen space.