Expose the save and restore key call back functionality.

This will allow user code to more easily create standalone dialogs just like the library does.
Modify the key handler save and restore to make it user proof by returning a restoration function not a table that could be modified.