Allow escape key to leave shell or pkg mode

It’s maybe just me who’d like to see this but I sometimes find myself writing julia commands in pkg or shell mode and wished there was a more direct way to switch to the correct mode than go to the start of the line and press backspace.

Would it be possible to map a key such as the ESC key for the same effect (i.e. you could press it at any time in shell> or pkg> mode and it would go to julia> mode?

pkg> println( # press [ESC] after realising I'm still in pkg>
# changes to
julia> println( # now I can complete the command and run it

That plus be able to toggle persistent and one time custom shell mode ( currently pkg> is permanent but most other not).
I am thinking of something like press mode character once to get single execution mode and press meta+mode character to get persistent mode, where meta is maybe Ctrl or Alt.

Seems like a good idea. Would you mind opening a feature request issue?