Redirect user to my app instead of Keycloak, if user won't give access to other IDP

I have added github as idp in keycloak, and in my github oauth app I have added keycloak redirect_uri as callback url.

I am redirecting user to keycloak, which internally redirects user to git hub login page. After login, on consent screen if user gives his consent, then github is redirecting back to keycloak with code in query parameter, which internally redirects back to my callback endpoint.
{base_url}/auth/realms/{realm}/broker/github/endpoint?code={code}&state={state}

However, if user doesn’t give his access, then github is redirecting to keycloak with error.
{base_url}/auth/realms/{realm}/broker/github/endpoint?error=access_denied&error_description=The+user+has+denied+your+application+access.&error_uri=https%3A%2F%2Fdocs.github.com%2Fapps%2Fmanaging-oauth-apps%2Ftroubleshooting-authorization-request-errors%2F%23access-denied&state={state}

Is there a way I can redirect user back to my application from Keycloak if user denied access.

Unfortunately not. Not out of the box, anyway.

An alternative to that is to set github as the default IDP on your browser authentication flow, so when the github login fails, keycloak login also fails and your application gets a login error which you can them treat and react accordingly.

Check the docs on how to set a default identity provider on Keycloak.