mattscy
|
  |
| Joined: 06 May 2011 |
| Total Posts: 1079 |
|
|
| 19 Sep 2017 08:09 PM |
I know how to use UserInputService to get the key the player pressed, but im unsure how to find the exact key entered. Right now I have this:
game:GetService("UserInputService").InputBegan:connect(function(key) print(string.char(key.KeyCode.Value)) end)
however, this doesnt work for capital letters or keyboards with different layouts. How would I fix this?
|
|
|
| Report Abuse |
|
|
Em_ily
|
  |
| Joined: 21 Jan 2014 |
| Total Posts: 1708 |
|
|
| 19 Sep 2017 08:10 PM |
| You have to use Enum . . . |
|
|
| Report Abuse |
|
|
LaeMVP
|
  |
| Joined: 24 Jun 2013 |
| Total Posts: 4416 |
|
|
| 19 Sep 2017 08:10 PM |
| print(tostring(key.KeyCode):match("%w+$")) |
|
|
| Report Abuse |
|
|
mattscy
|
  |
| Joined: 06 May 2011 |
| Total Posts: 1079 |
|
|
| 19 Sep 2017 08:12 PM |
I need it to work for symbols too
|
|
|
| Report Abuse |
|
|
mattscy
|
  |
| Joined: 06 May 2011 |
| Total Posts: 1079 |
|
|
| 19 Sep 2017 08:25 PM |
for example
if the player holds shift and presses 4, the dollar sign (or whatever alternate key it is for them) will be printed
if the player is holding shift and press a letter it will give a capital, but if not it will give a lowercase
I basically need to get the key that would come up if they typed a letter into a textbox
|
|
|
| Report Abuse |
|
|
chimmihc
|
  |
| Joined: 01 Sep 2014 |
| Total Posts: 17143 |
|
| |
|
mattscy
|
  |
| Joined: 06 May 2011 |
| Total Posts: 1079 |
|
| |
|
cabbler
|
  |
| Joined: 19 Jun 2015 |
| Total Posts: 735 |
|
|
| 19 Sep 2017 08:37 PM |
| raw input does not handle uppercase stuff. you can check yourself it's not too hard |
|
|
| Report Abuse |
|
|
|
| 19 Sep 2017 08:38 PM |
local shiftDown = false
UIP.InputBegan:Connect(function(keycode)
if keycode.KeyCode == Enum.Keycode.Shift then
shiftDown = true
elseif keycode.KeyCode:match(%w) and shiftDown then
print("capital")
end
end)
UIP.InputEnded:Connect(function(keycode)
if keycode.KeyCode = Enum.KeyCode.Shift then
shiftDown = false
end
end
something like that |
|
|
| Report Abuse |
|
|
mattscy
|
  |
| Joined: 06 May 2011 |
| Total Posts: 1079 |
|
|
| 19 Sep 2017 08:44 PM |
capitalisation isnt my only problem, if you have a keyboard from a different country raw input messes up the symbols too. Will I just have to force the player to focus on a textbox, and whatever letter they type into there I record?
|
|
|
| Report Abuse |
|
|