If you are a Windows Phone app developer and building a Camera application, you might want to know whether the user pressed the shutter key half or full. In general pressing the shutter key half sets the focus to an object and pressing it completely captures the view.

 

In this short blog post, we will learn how to subscribe for the shutter key press events and identify whether the user pressed it half or full.

 

The Windows Phone SDK provides a static class named “CameraButtons” available in “Microsoft.Devices” namespace, which provides events to know whether the user triggered the device shutter button. The class available in “Microsoft.Phone.dll” exposes three events named:

    • ShutterKeyHalfPressed – Occurs when the camera shutter key button receives a half press event.
    • ShutterKeyPressed – Occurs when the camera shutter key button receives a full press event.
    • ShutterKeyReleased – Occurs when the camera shutter key button released after the ShutterKeyPressed event occurs.

As these are static events, you don’t need to create any instance of Camera object or CameraButtons object. You can directly register the events of the static class and write your business logic based on your requirement. Here is how you can use these events:

 

CameraButtons.ShutterKeyHalfPressed += (s, e) => UpdateHistory("Shutter Key Half Pressed");
CameraButtons.ShutterKeyPressed += (s, e) => UpdateHistory("Shutter Key Pressed");
CameraButtons.ShutterKeyReleased += (s, e) => UpdateHistory("Shutter Key Released");

 

In our sample demo, the UpdateHistory(…) method prints the Shutter Key press event log in the phone screen. Here is what you might notice (similar) when you press the shutter in half press, full press and/or release the full shutter press:

 

Shutter Key events in Windows Phone Camera

 

I hope this now gives you some basic idea to know the Camera Shutter Button events and based on that you can write your own logic to do various kinds of operations in your application. As I said above, generally when a user presses half shutter key, the camera view finder focuses the camera to a specific point. When the user presses full shutter key, it executes a command to capture the view and/or starts the video capture.

 

Don’t forget to read another blog post on Windows Phone Camera APIs (“How to check the supported Camera Type in Windows Phone?”). Subscribe to my blog to get updates on latest articles. I am available on Twitter and Facebook too. Connect with me and say a “Hi”. Happy Coding!!!

 

Have a question? Or, a comment? Let's Discuss it below...

Thank you for visiting our website!

We value your engagement and would love to hear your thoughts. Don't forget to leave a comment below to share your feedback, opinions, or questions.

We believe in fostering an interactive and inclusive community, and your comments play a crucial role in creating that environment.