Rewrite powerkey handler to allow more flexible configuration