AZERTY Keyboard inputs not the same as the requested key types

Basically, in my game, normally when you’re trying to press a keybind on a QWERTY keyboard, the requested keybind will pass through as normal, but on an AZERTY keyboard, it’s switched over to different keys that aren’t normal.

For example, when you press A, the Q keybind fires and does the event.

Here’s the code, for one of the keybind detectors,

local PService = game:GetService("Players")
local UIS = game:GetService("UserInputService")
local Player = PService.LocalPlayer

local Tool = script.Parent
local StarterPack = Tool.Parent

local TM = require(StarterPack:WaitForChild("ToolManagment"))

local PGui = Player.PlayerGui
local ModuleList = PGui:WaitForChild("Tools"):WaitForChild(Tool.Name)

local Connections = {}

local Keybinds = script:WaitForChild("Keybinds")

local function Clicked(Key, GameProcessedEvent)
	if TM.GetUsing() or GameProcessedEvent then
		return
	end

	local KeyString = UIS:GetStringForKeyCode(Key.KeyCode)

	if Key.UserInputType == Enum.UserInputType.MouseButton1 then
		KeyString = "LMB"
	elseif Key.UserInputType == Enum.UserInputType.MouseButton2 then
		KeyString = "RMB"
	end

	local Information = require(Keybinds)[KeyString]

	if Information ~= nil then
		for Action, Chargable in pairs(Information) do
			local Module = require(ModuleList:FindFirstChild(Action))

			if Chargable == false then
				Module:Activate()
			else
				Module:Held()				
			end
		end
	end
end


local function Released(Key, GameProcessedEvent)	
	local KeyString = UIS:GetStringForKeyCode(Key.KeyCode)

	if Key.UserInputType == Enum.UserInputType.MouseButton1 then
		KeyString = "LMB"
	elseif Key.UserInputType == Enum.UserInputType.MouseButton2 then
		KeyString = "RMB"
	end

	local Information = require(Keybinds)[KeyString]

	if Information ~= nil then
		for Action, Chargable in pairs(Information) do

			if Chargable == true then
				local Module = require(ModuleList:FindFirstChild(Action))
				Module:Released()	
			end
		end
	end
end

Tool.Equipped:Connect(function()
	local Connection = UIS.InputBegan:Connect(Clicked)
	local Connection2 = UIS.InputEnded:Connect(Released)

	table.insert(Connections, Connection)
	table.insert(Connections, Connection2)
end)

Tool.Unequipped:Connect(function()
	for Index, KeyConnections in ipairs(Connections) do
		if KeyConnections ~= nil then
			KeyConnections:Disconnect()
			KeyConnections = nil
		end
	end
end)

Keybinds module:

return {
	Q = {
		["HighDiveLeft"] = false
	},

	E = {
		["HighDiveRight"] = false
	},

	H = {
		["FrontSweep"] = false
	},

	C = {
		["LowDiveRight"] = false
	},

	Z = {
		["LowDiveLeft"] = false
	},

	R = {
		["HighCatch"] = false
	},

	T = {
		["Throw"] = true
	},

	Y = {
		["FrontalDive"] = false
	},

	F = {
		["LowCatch"] = false
	},	

	X = {
		["QuickReflexes"] = false
	},

	V = {
		["Parry"] = true
	},

	LMB = {
		["Clear"] = true
	},

	K = {
		["TipLeft"] = false
	},

	L = {
		["TipRight"] = false
	}
}

Any ideas on how to fix this would be great, thanks!

To anyone having the same issue as me, simply change the UIS method to the Mouse.KeyDown method as that seems to fix it.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.