The Cordova API exposes two events that might be helpful in your case:
- pause: the event fires when the native platform puts the application into the background, typically when the user switches to a different application.
- resume: the event fires when the native platform pulls the application out from the background.
Other than that I am not aware of a specific set of events you can use to detect exactly when the device is locked or not. However, if you need to prevent the screen from dimming (and locking the device) while the user is not touching the screen but running your app, you can try the Insomnia plugin