add in keyfile support

This is a cherry-picked clean commit from #40

This adds key-file support

Credit goes to @lackac