Output text
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Output text
For example if I press "U" + "right Alt" i got "€". Is it possible to make that in Love2D using another characters (not pre-programmed)?. I want do that if I press "P" + "right Alt" i get "ч".
Re: Output text
Are you talking about text inputs, or changing the key when a key is pressed for the callback?
- zorg
- Party member
- Posts: 3468
- Joined: Thu Dec 13, 2012 2:55 pm
- Location: Absurdistan, Hungary
- Contact:
Re: Output text
It's a bit complicated;
if you want more control over things, then handle key presses with love.keypressed and love.keyreleased (and use the scancode parameter!), and just create your own "mapping table" between scancodes and your own symbols... though you'll need extra work to get combining keys to be detected and such.
A bit simpler would be to use love.textinput, and swap those characters out for whatever you want, though some keys or key combinations may map to the same symbol (like the alpha-dash key next to the right shift, and the minus key on the numpad), so you'd still need to use this in conjunction with the above method to actually detect what key was pressed...
OR if you just want russian input, then if your keyboard -is- set to that, love.textinput -will- (or at least should) give you back the correct characters.
For key detection, scancodes still work regardless of keyboard layout.
if you want more control over things, then handle key presses with love.keypressed and love.keyreleased (and use the scancode parameter!), and just create your own "mapping table" between scancodes and your own symbols... though you'll need extra work to get combining keys to be detected and such.
A bit simpler would be to use love.textinput, and swap those characters out for whatever you want, though some keys or key combinations may map to the same symbol (like the alpha-dash key next to the right shift, and the minus key on the numpad), so you'd still need to use this in conjunction with the above method to actually detect what key was pressed...
OR if you just want russian input, then if your keyboard -is- set to that, love.textinput -will- (or at least should) give you back the correct characters.
For key detection, scancodes still work regardless of keyboard layout.
Me and my stuff True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
Re: Output text
I not only want detecting pressed buttons, I want too writting it like they was on keyboard.
Like that: http://russian.typeit.org/
I'm pressing "i" and get "и". I want make program that will detect when I'm pressing "P" + "right Alt" and it will output "ч" like it was default keyboard combination, like "U" + "right Alt" = "€". I want use that for example in browser.
Like that: http://russian.typeit.org/
I'm pressing "i" and get "и". I want make program that will detect when I'm pressing "P" + "right Alt" and it will output "ч" like it was default keyboard combination, like "U" + "right Alt" = "€". I want use that for example in browser.
Re: Output text
Do you wan't to change Keyboard Layout?
The Microsoft Keyboard Layout Creator
The Microsoft Keyboard Layout Creator
- zorg
- Party member
- Posts: 3468
- Joined: Thu Dec 13, 2012 2:55 pm
- Location: Absurdistan, Hungary
- Contact:
Re: Output text
Code: Select all
-- Define your own substitutions.
local map = {
-- ctrl/alt/shift 0-not held, 1- held; key's scancode
['000i'] = 'и',
['001i'] = 'И',
-- etc.
}
love.keypressed = function(scancode)
local ctrl = love.keyboard.isDown('rctrl','rctrl') and 1 or 0
local alt = love.keyboard.isDown('ralt','lalt') and 1 or 0
local shift = love.keyboard.isDown('rshift','lshift') and 1 or 0
local key = ('%1d%1d%1d%s'):format(ctrl,alt,shift,scancode)
-- and finally, use map[key] in whatever way you prefer, and you'll get whatever character you defined above.
end
Code: Select all
local map = {
-- utf-8 character maps to utf-8 character.
['i'] = 'и',
['I'] = 'И',
-- etc.
}
love.textinput = function(text)
-- use map[text] in whatever way you prefer.
end
Me and my stuff True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
Re: Output text
That's it. Thanks.MasterLee wrote: ↑Sun Jun 25, 2017 10:58 am Do you wan't to change Keyboard Layout?
The Microsoft Keyboard Layout Creator
Who is online
Users browsing this forum: Ahrefs [Bot], Amazon [Bot], Bing [Bot], Google [Bot], Semrush [Bot] and 6 guests