Mac keyboard on powered hub does not work initially
Solution 1:
You should try using the keyboard extension cable that comes with your keyboard. For somewhat obscure reasons, this solved the problem for me and other people trying to use the Apple Wired Keyboard with USB hubs. See also https://apple.stackexchange.com/a/179299/33925