Gtk.Widget.prototype.is_focus

function is_focus():Boolean {
    // Gjs wrapper for gtk_widget_is_focus()
}

Determines if the widget is the focus widget within its toplevel. (This does not mean that the %HAS_FOCUS flag is necessarily set; %HAS_FOCUS will only be set if the toplevel widget additionally has the global input focus.)

Returns

true if the widget is the focus widget.