This mod adds components to get text input from player. It simply acts as a library for other mods that need such a tool.

End user side

Text selection

You can select text by holding Shift and moving caret or simply using your mouse.

Special keys

Here are all the functions supported when entering text:

Numpad Enteradd new line
Entervalidate operation
Esccancel operation
Ctrl + Ccopy text to clipboard
Ctrl + Vpaste text from clipboard
Ctrl + Xcut selected text to clipboard
Up Arrowmove caret to the line above
Down Arrowmove caret to the line below
Left Arrowmove caret by 1 character to the left
Ctrl + Left Arrowmove caret by 1 word to the left
Right Arrowmove caret by 1 character to the right
Ctrl + Right Arrowmove caret by 1 word to the right
Homemove caret to beginning of line
Ctrl + Homemove caret to beginning of text
Endmove caret to end of line
Ctrl + Endmove caret to end of text
Page Upmove caret to previous page
Page Downmove caret to next page
Backspaceerase previous character
Ctrl + Backspaceerase previous word
Delerase next character
Ctrl + Delerase next word


If you're a mod maker, read what follows!


To declare QuickKeyboardInput as a dependency, first you need , then just add the following lines to your mod.txt:

"simple_dependencies" : {
	"QuickKeyboardInput": "http://pd2mods.z77.fr/update/QuickKeyboardInput.zip"

Example of modal use

This short piece of code...

function qki_callback_ok(text)
    log("user typed: " .. tostring(text))

local title = 'Title'
local message = 'Message'
local params = {
	default_value = 'default',
	changed_callback = qki_callback_ok
local show_immediately = true

QuickKeyboardInput:new(title, message, params, show_immediately)

...will produce this result:

Example of non-modal use

You can easily render any panel:text() object editable by using class QuickKeyboardInputHusk.

First, you create event callbacks:

function ThingYouArePatching:accept_callback(text)
	self.qki = nil
	-- do something with variable text

function ThingYouArePatching:cancel_callback()
	self.qki = nil

Then you initialize it where needed with current workspace, text object and callbacks:

self.qki = QuickKeyboardInputHusk:new(workspace, text_object, {
	changed_callback = callback(self, self, 'accept_callback'),
	cancel_callback = callback(self, self, 'cancel_callback')

To know if user is currently editing something, you just check on self.qki.

For a real use case, this is implemented in to manage text typed to filter items; look for self.si_qki in its files.


cancel_callbackfunctioncalled if aborted
changed_callbackfunctioncalled on success, typed text is found in first parameter
changing_callbackfunctioncalled on each change, typed text is found in first parameter
set_selection_fromnumberdefine position of caret
set_selection_tonumberpreselect text
halignstringhorizontal alignment of typed text, expected values are left, center and right
valignstringvertical alignment of typed text, expected values are top, center and bottom
max_lengthnumbermaximum number of characters
max_sizenumbermaximum number of bytes
multilinebooleanif false then typing numpad enter won't have any effect
wnumberset a specific width on dialog box
forced_hnumberforce a specific height on dialog box
max_linesnumberlimit autoresize, if you define a limit of 5 and type 10 lines, a scrollbar will appear
no_mousebooleanhide mouse cursor
no_cornersbooleanremove dialog corners, only effective for modal use
not_editablebooleanprevent text modifications but not selection
scroll_by_x_linesnumberspecify by how many lines to scroll when using mouse wheel, default value is 3