Skip to content
Course briefing · 25 min

Key events & conditions

Build an F6 action and prove that other keys do nothing.

1

Respond to an event

A real script can subscribe to KeyDown and handle a KeyEventArgs argument. This lab supplies that handler context as e. It runs your method body with the selected F5, F6, or F7 key. Event subscription belongs in the complete script, outside this snippet.

2

Use comparison, not assignment

The expression e.KeyCode == Keys.F6 compares the incoming key. An if block executes its braced statements only when the condition is true. Put the health change and notification inside the block.

3

Test the negative case

A keybind is incomplete if every key triggers it. F6 must set health to 200 and display Recovered. F5 and F7 must leave health at 100 and display nothing. The checkpoint runs all three cases independently.

Script Hook V .NET: event-based scripts

Explore as a guest. Your current lab resumes in this browser session. Sign in before learning to save course completions to your account.

Sign in to save progress →