Draw Power from Light Switch?

I would like to mount a tablet above a light switch in an upstairs hall. I want it to be permanently powered through a USB cable. Is there a device that would mount inside the wall, wired to the light switch, that would supply USB power and meet U.S. electrical codes?

There are multiple devices available for sale which have a USB port in a light switch. They’re quite easy to install. Would that work for you? Pass & Seymour make several.

You can also find quite a few power discussions in the dashboard mounting thread.