---
title: "Device Info and App Events"
canonical_url: https://developer.repebble.com/guides/alloy/device-info/
last_updated: 2026-08-12
sdk_version: 4.43
---
# Device Info and App Events

Source: https://developer.repebble.com/guides/alloy/device-info/

Alloy exposes information about the watch and screen through the `watch`, `screen`, and `device` globals, delivers app lifecycle events through `watch`, and lets you control the backlight with `watch.light()`.

> **Platform Support** : These APIs are available on Emery (Pebble Time 2) and Gabbro (Pebble Round 2).

## Watch Information

The `watch` global describes the device and the user's preferences:

```
console.log(`watch.model ${watch.model}`);console.log(`firmware ${watch.firmwareVersion.major}.${watch.firmwareVersion.minor}.${watch.firmwareVersion.patch}`);console.log(`user prefers ${watch.hour12 ? "12" : "24"} hour display`);
```

| Property | Description |
| --- | --- |
| `watch.model` | The watch model identifier. |
| `watch.firmwareVersion` | Object with `major`, `minor`, and `patch` numbers. |
| `watch.hour12` | `true` if the user prefers a 12-hour clock, `false` for 24-hour. |
| `watch.launch` | How the app was launched: `reason` and `arguments`. |
| `watch.wake` | Present when launched by a wakeup; see [_Wakeups_](https://developer.repebble.com/guides/alloy/wakeups.md). |

## Screen Properties

The `screen` global describes the display:

```
console.log(`screen ${screen.width} x ${screen.height}`);console.log(`round ${screen.round}, color ${screen.color}`);
```

| Property | Description |
| --- | --- |
| `screen.width` | Display width in pixels. |
| `screen.height` | Display height in pixels. |
| `screen.round` | `true` on round displays (Gabbro). |
| `screen.color` | `true` on color displays. |

## Device Sensors

The `device.sensor` object reports which sensors are available, so you can feature-detect before using one:

```
const hasTouch = device.sensor.Touch ? true : false;console.log(`touch available ${hasTouch}`);
```

## App Lifecycle and Display Events

Subscribe to app events on `watch` with `addEventListener`:

```
watch.addEventListener("willFocus", inFocus =\> {console.log(`willFocus with inFocus ${inFocus}`);});watch.addEventListener("didFocus", inFocus =\> {console.log(`didFocus with inFocus ${inFocus}`);});watch.addEventListener("resize", progress =\> {console.log(`screen resized to ${screen.width} x ${screen.height} at progress ${progress}`);});
```

| Event | Description |
| --- | --- |
| `"willFocus"` | The app is about to gain or lose focus. The handler receives `inFocus`. |
| `"didFocus"` | The app has gained or lost focus. The handler receives `inFocus`. |
| `"resize"` | The drawable area is changing size (for example during an animation). The handler receives the animation `progress`. |

The `watch` global also delivers `"secondchange"`/`"minutechange"` time events (see [_Watchfaces_](https://developer.repebble.com/guides/alloy/watchfaces.md)), a `"wakeup"` event (see [_Wakeups_](https://developer.repebble.com/guides/alloy/wakeups.md)), and `"health"` events when new health data arrives (see [_Health_](https://developer.repebble.com/guides/alloy/health.md)).

## Controlling the Backlight

Use `watch.light()` to control the backlight:

```
watch.light(true);// force the backlight onwatch.light(false);// turn the backlight offwatch.light();// turn on temporarily, as if the user interacted
```

Calling `watch.light()` with no argument turns the backlight on for the standard auto-off interval, just like a button press or shake would. Passing a boolean forces the backlight on or off.

> **Note** : Holding the backlight on draws significantly more power than letting it auto-off. Only force it on for short, deliberate interactions.

See the [`helloinfo`](https://github.com/Moddable-OpenSource/pebble-examples/tree/main/helloinfo), [`helloappevents`](https://github.com/Moddable-OpenSource/pebble-examples/tree/main/helloappevents), and [`hellolight`](https://github.com/Moddable-OpenSource/pebble-examples/tree/main/hellolight) examples for complete projects.
