You can't do that, CS. The logic has an ill in it.
It's too late to enable/disable the SHIFT key once the db is open and
running code.
That would require a Time Machine...which would become recursive...
You CAN change the SHIFT key for the NEXT time the db is run; but this would
usually be used just to reset it for the developer (say).
Why worry about disabling the SHIFT key? Instead, enable or disable F11
(or some code equivalent) to provide access to the db window AFTER it's open.
----------
There is no event which can be force-run on database close. A hidden form is
the nearest you'll get. It is subject to the vagiaries of ULS security, of
course.
----------
Imagining your logic would work (!!!), you wouldn't set it against a User,
you'd set it against a Group and see if they belong to that Group (using code,
ULS itself would be asking a bit much)
----------
So the Shift key HAS to be disabled every time the database is closed.
I hope my explanation is clear.
Perfectly.
Don't muck with it in a production environment;leave it disabled.
If the shift key is disabled when closed then it's disabled when next opened.
There is NO case (apart from developer access) where I can imagine any user
needing the db not to run (and db window can be provided later if necessary).
A developer (regarding AllowBypassKeys) would, I imagine, reset the flag by
some secret method, open it again, do their stuff, then set the
AllowBypassKeys prior to despatch.
Or dispatch, either the db or the developer
Chris