Hardware keys don't work for wearable_clock category

I’m trying to use window.addEventListener("tizenhwkey", keyEventHandler); in a web watchface application. Here’s the code:

window.addEventListener("tizenhwkey", keyEventHandler);
function keyEventHandler(event) { console.log('event!', event); alert("back key pressed!"); }

When I use <tizen:category name="http://tizen.org/category/wearable_clock"/> in the config file, the event handler won’t work. The callback is never hit. Though when I remove the category from my config, the code works.

Is there a way to use hardware keys in a wearable_clock application?

In Gear or Tizen Wearable Emulator a “Watchface” plays the role of ‘Home Screen’. A ‘home screen app’ can’t have eventListeners for Hardware keys as the keys have different functions/works to do in that state. (For example: Home key (the lower button) opens the app drawer ). That’s why tizenhwkey eventListeners are not working for Watchface app.

1 Like

Try this:

window.addEventListener('tizenhwkey', function( ev ) {
	if( ev.keyName == "back" ) {			
		console.info("HW BACK KEY PRESSED");
                   // your code

It works for me on watch face project.

Thank you! This is a helpful explanation.

Thank you for your suggestion! How is this code different than what I posted though? Does your watch face project have the wearable_clock category specified in it’s config?

1 Like

Is there a way to get this functionality via partner level or platform level api’s?

As far as I know there is no such API for this functionality.

After checked out you can’t use HW Back event on watch face. Use custom navigation instead like UI button. Watch face is not regular app. Most events don’t work like HW keys and scrolling gestures.

You mean on a watch face, you can press the back button and get your code running? It does not seem to work here.

This code will work only in case regular app not watch face. My fault, I didn’t check in my code and wrote from memory. I was wrong. Again, HW events like Back don’t work in case watch face. It just can’t. Watch face is like home screen app.

Yes, thanks for the feedback.

PS: do you know of any other gestures I can use for interactive watch face besides tap?