Microsoft Small Basic

Program Listing: WGP487
' Background Color Changer
' Copyright © 2018 Nonki Takahashi. The MIT License.
' Challenge 2018-07

help = "Hit [Shift+]{R|G|B} Key"
color = "1=127;2=127;3=127;"
SetBackgroundColor()
GraphicsWindow.KeyDown = OnKeyDown
GraphicsWindow.KeyUp = OnKeyUp

Sub OnKeyDown
key = GraphicsWindow.LastKey
i = Text.GetIndexOf("RGB", key)
If 0 < i Then
If shift Then
If 0 < color[i] Then
color[i] = color[i] - 1
EndIf
Else
If color[i] < 255 Then
color[i] = color[i] + 1
EndIf
EndIf
SetBackgroundColor()
ElseIf Text.IsSubText(key, "Shift") Then
shift = "True"
EndIf
EndSub

Sub OnKeyUp
key = GraphicsWindow.LastKey
If Text.IsSubText(key, "Shift") Then
shift = "False"
EndIf
EndSub

Sub SetBackgroundColor
GraphicsWindow.BackgroundColor = GraphicsWindow.GetColorFromRGB(color[1], color[2], color[3])
GraphicsWindow.Title = "rgb(" + color[1] + "," + color[2] + "," + color[3] + ") - " + help
EndSub