Side menu close on phone back button press


I have sidemenu page and now after opening the side menu when i click on back button its going back instead of closing back side menu.
help me…

here is ionic info:

Ionic CLI : 5.4.13
Ionic Framework : @ionic/angular 4.11.7
@angular-devkit/build-angular : 0.801.3
@angular-devkit/schematics : 8.1.3
@angular/cli : 8.1.3
@ionic/angular-toolkit : 2.1.1


Cordova CLI : 9.0.0 (cordova-lib@9.0.1)
Cordova Platforms : android 8.1.0
Cordova Plugins : cordova-plugin-ionic-keyboard 2.2.0, cordova-plugin-ionic-webview 4.1.3, (and 4 other plugins)


cordova-res : 0.8.1
native-run : 0.3.0


Android SDK Tools : 26.1.1
NodeJS : v10.16.2
npm : 6.9.0
OS : Windows 10

If you need to do this, the first thing you should do is capture the event when you press the back button. Once this is done you should close the side menu by code. A few days ago place how it works and capture the backbutton for ionic 4 so you can go for a spin and try to implement it.

if you have any questions with this or with the implementation try to place your code so we can guide you

Thanks for your response. how i detect sidemenu is open or close from