Hello guys I'm facing a problem that two of my keyboard key is not working i.e.(LShift and RShift) so I want to replace one of them with other key i.e.(RCtrl).While I was trying to re-map these keys through windows registry(run-regedit-HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout\Scancodes Map)but the problem is that I don't know the actual scan codes for my laptop keyboard layout.My laptop product name is "HP 15 Notebook PC".I also use some third party softwares for re-mapping my keys and check out Microsoft Key Scan Codes list but none of these were useful for me.So can someone please help me out to resolve this issue by providing me right scan codes for my keyboard or any type of correct link?
1 Answer
Here's a PowerShell script I wrote that allows for edits to the remap pairs --- adding or removing --- and creates a ScanCode Map byte array from those pairs.
In your case:
- LShift = 0x2a
- LCtrl = 0x1d
- RShift = 0x36:EXtended
- RCtrl = 0x1d:Extended
Note that "#" specifies a comment in PowerShell, so those lines are not executed.
As changes need to be made to HKLM, you mustcopy & paste the following code in an Administrative PowerShell console.:
##############################################################
$SimplePairs = @(
# 0x2a, 0x1d # LShift > LCtrl
)
$ExtendedPairs = @(
0x2a, 0x00, 0x1d, 0xe0 # LShift > RCtrl
)
$ByteCount = 2 * $SimplePairs.Length + $ExtendedPairs.Length + 16
$Remap = New-Object -TypeName byte[] -ArgumentList $ByteCount
$Remap[8] = $SimplePairs.Length/2 + $ExtendedPairs.Length/4 + 1
For ($i = 0 ; $i -lt $SimplePairs.Length ; $i += 2) {
$Remap[$i * 2 + 12] = $SimplePairs[$i]
$Remap[$i * 2 + 14] = $SimplePairs[$i + 1]
}
For ($i = 0 ; $i -lt $ExtendedPairs.Length ; $i += 4) {
$Offset = $SimplePairs.Length * 2
$Remap[$i + 12 + $Offset] = $ExtendedPairs[$i]
$Remap[$i + 13 + $Offset] = $ExtendedPairs[$i + 1]
$Remap[$i + 14 + $Offset] = $ExtendedPairs[$i + 2]
$Remap[$i + 15 + $Offset] = $ExtendedPairs[$i + 3]
}
$Splat = @{
Path = 'HKLM:\SYSTEM\CurrentControlSet\Control\Keyboard Layout'
Name = 'ScanCode Map'
Value = $Remap
Force = $True
}
# $Splat['Value'] | format-hex
New-ItemProperty @Splat
-
Keith can you please tell me what this script is actually doing?Extremely sorry for getting your too much time but I want to make things clear before I am going to apply it.Once again I am telling you that I only want to map/replace LShift key to/with RCtrl key thats it.– ITianCommented Apr 13, 2020 at 23:33
-
OK, I'll modify the single remap. This was doing both., Commented Apr 13, 2020 at 23:45
-
Yes that's why I again explain it to you and keith please also explain me that script and what I do further now?– ITianCommented Apr 14, 2020 at 10:11
-
Copy & paste the code into and Administrative PowerShell window. It will create a
ScanCode Map
value that will remap the right Ctrl key to send a Left Shift. If you want me to explain more, you have to ask specific questions. Commented Apr 14, 2020 at 16:54
ScanCode Map
value.SanCode Map
value in the registry that (perhaps inadvertently) is remapping your<Shift>
keys to<Null>
.