Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 3 Next »

In some custom integrations you may want to use some keyboard shortcuts to allow quick emoji insertion.

CTLive Agent SDK offers an object hash that contains all the Unicode 11 Emoji shortnames and symbols.

LIVECHATSDK.LIVECHAT.emojiShortNames

Using a regular expression pattern we can define a special sequence of characters (like : shortname:) to search and replace with the equivalent emoji stored in the LIVECHATSDK.LIVECHAT.emojiShortNames hash.

The following code search for any shortname that matches the last typed word with preceding and following “:” character. Example :grinning_face: (big grin)

jQuery("#mytextarea").on("change keyup", 
  function() {
    var text = jQuery("#mytextarea").val();
    text = text.replace(/:(\w+):$/gi,
      function(all, code) {
        // Emoji Match
        return LIVECHATSDK.LIVECHAT.emojiShortNames[code] || code;
      }
    );
    jQuery("#mytextarea").val( text );
  }
);

  • No labels