letterNoteMap="\049\033\050\064\051\052\036\053\037\054\094\055\056\042\057\040\048\113\081\119\087\101\069\114\116\084\121\089\117\105\073\111\079\112\080\097\115\083\100\068\102\103\071\104\072\106\074\107\108\076\122\090\120\099\067\118\086\098\066\110\109"function LetterToNote(v,U,L)local C=letterNoteMap:find(string.char(v),1,true)if C then return(C+Transposition.Value)+(U and 1 or L and-1 or 0)end end function KeyDown(v)if TextBoxFocused then return end local U=v.KeyCode.Value if U>=97 and U<=122 or U>=48 and U<=57 then local v=LetterToNote(U,(InputService:IsKeyDown(303)or InputService:IsKeyDown(304))~=ShiftLock,InputService:IsKeyDown(305)or InputService:IsKeyDown(306))if v then do local L L=InputService.InputEnded:connect(function(v)if v.KeyCode.Value==U then L:disconnect()end end)PlayNoteClient(v)end else PlayNoteClient(v)end elseif U==8 then Abort()elseif U==32 then ToggleSheets()elseif U==13 then ToggleCaps()elseif U==274 then Transpose(-1)elseif U==273 then Transpose(1)elseif U==275 then VolumeChange(.1)elseif U==276 then VolumeChange(-0.1)end end function Input(v)local U=v.UserInputType.Name local L=v.UserInputState.Name if U=="\075\101\121\098\111\097\114\100"then if L=="\066\101\103\105\110"then if FocusLost then FocusLost=false return end KeyDown(v)end end end function TextFocus()TextBoxFocused=true end function TextUnfocus()FocusLost=true TextBoxFocused=false end
----------------------------------
------------FUNCTIONS-------------
----------------------------------

letterNoteMap = "1!2@34$5%6^78*9(0qQwWeErtTyYuiIoOpPasSdDfgGhHjJklLzZxcCvVbBnm"
function LetterToNote(key, shift, ctrl)
	local note = letterNoteMap:find(string.char(key), 1, true)
	if note then
		return note + Transposition.Value + (shift and 1 or ctrl and -1 or 0)
	end
end

function KeyDown(Object)
	if TextBoxFocused then
		return
	end
	local key = Object.KeyCode.Value
	if key >= 97 and key <= 122 or key >= 48 and key <= 57 then
		local note = LetterToNote(
			key,
			(InputService:IsKeyDown(303) or InputService:IsKeyDown(304)) ~= ShiftLock,
			InputService:IsKeyDown(305) or InputService:IsKeyDown(306)
		)
		if note then
			do
				local conn
				conn = InputService.InputEnded:connect(function(obj)
					if obj.KeyCode.Value == key then
						conn:disconnect()
					end
				end)
				PlayNoteClient(note)
			end
		else
			PlayNoteClient(note)
		end
	elseif key == 8 then
		Abort()
	elseif key == 32 then
		ToggleSheets()
	elseif key == 13 then
		ToggleCaps()
	elseif key == 274 then
		Transpose(-1)
	elseif key == 273 then
		Transpose(1)
	elseif key == 275 then
		VolumeChange(0.1)
	elseif key == 276 then
		VolumeChange(-0.1)
	end
end

function Input(Object)
	local type = Object.UserInputType.Name
	local state = Object.UserInputState.Name -- in case I ever add input types
	if type == "Keyboard" then
		if state == "Begin" then
			if FocusLost then -- this is so when enter is pressed in a textbox, it doesn't toggle caps
				FocusLost = false
				return
			end
			KeyDown(Object)
		end
	end
end

function TextFocus()
	TextBoxFocused = true
end
function TextUnfocus()
	FocusLost = true
	TextBoxFocused = false
end
