Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merging Two Word #769

Closed
Yateenp88 opened this issue Feb 8, 2020 · 4 comments
Closed

Merging Two Word #769

Yateenp88 opened this issue Feb 8, 2020 · 4 comments

Comments

@Yateenp88
Copy link

i have query regarding joining two word and form different single word.Please help

@Mottie
Copy link
Owner

Mottie commented Feb 8, 2020

Hi @Yateenp88!

You can't use the combo's feature because it only examines the last two characters that were typed, this was done to prevent replacements from always occurring.

But, good news, you can use the change callback to alter the text of the input (demo)

$(function() {
  var wordsToChange = 'two words';
  var newWord = 'oneNEWword';

  $('#keyboard').keyboard({
      change: function(event, kb) {
        var $el = kb.$preview;
        var text = $el.val();
        if (text.includes(wordsToChange)) {
          var newText = text.replace(wordsToChange, newWord);
	        $el.val(newText);
          // move caret to end of new word
	        $.keyboard.caret($el, newText.indexOf(newWord) + newWord.length);
        }
      }
    })
    // activate the typing extension
    .addTyping({
      showTyping: true,
      delay: 250
    });

In that demo:

  • Click the keyboard icon next to the input to get it to start typing. Once it's done, enter "o" to see the change happen.
  • It doesn't seem like you can use addTyping to update the input, but you can. You'll need to change the code to use an event listener for the keyboardChange event and look for the text to change, thenin the addTyping callback, trigger this event.
  • I set the caret position to be at the end of the new word. If you want it somewhere else, or to not move at all, remove the $.keyboard.caret line.
  • I only set the demo up for one set of word replacements, but it can be set it up for more than one set. If you need help with this, please feel free to ask.

@Yateenp88
Copy link
Author

thanks buddy....help me lots

@Yateenp88 Yateenp88 reopened this Feb 23, 2020
@Yateenp88
Copy link
Author

is combo's limited for ligature character only..

@Mottie
Copy link
Owner

Mottie commented Feb 23, 2020

is combo's limited for ligature character only

No, any two characters can be used. I think I'll add an option to expand this limit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants