July 30, 2026 — The unofficial Laracon US Day 3. Get your ticket to The Vibes

Global Shortcut


Fake Global Shortcuts#

Example test case#

Copied!
use Native\Desktop\Facades\GlobalShortcut;
 
#[\PHPUnit\Framework\Attributes\Test]
public function example(): void
{
GlobalShortcut::fake();
 
$this->get('/whatever-action');
 
GlobalShortcut::assertKey('CmdOrCtrl+,');
GlobalShortcut::assertRegisteredCount(1);
GlobalShortcut::assertEvent(OpenPreferencesEvent::class);
}

Available assertions#

  • assertKey
  • assertRegisteredCount
  • assertUnregisteredCount
  • assertEvent