Linux - keyboard layout sometimes correct, sometimes not

This issue happens to me whether I use the official appimage or the build on flathub, so I suspect it’s an issue with Obsidian itself.

I use debian testing with the gnome desktop environment. I use a UK English keyboard layout. Sometimes when I launch Obsidian, it seems not to use the correct keyboard layout and appears to default to a US layout (the #~ key producing backslashes gives it away). Sometimes I can get it to work correctly by switching back and forth between different layouts in gnome settings, sometimes I can’t. It seems very unpredictable.

Can you help me troubleshoot this?