{"id":7278731,"date":"2016-04-14T21:26:28","date_gmt":"2016-04-14T21:26:28","guid":{"rendered":"https:\/\/wordpress.org\/support\/topic\/delete-bug\/"},"modified":"2016-08-31T15:54:32","modified_gmt":"2016-08-31T15:54:32","slug":"delete-bug","status":"publish","type":"topic","link":"https:\/\/wordpress.org\/support\/topic\/delete-bug\/","title":{"rendered":"Delete bug"},"content":{"rendered":"<p>Your plugin has a bug when using the delete key. If you type 5 letters using the keyboard, and then hit delete 6 times, it will &#8220;store&#8221; the last delete and move the cursor to the left when you start typing again, so if I type &#8220;sport&#8221; followed by 6 delete presses, then type &#8220;sport&#8221; again, it actually shows &#8220;ports&#8221;. The more delete keys you press, the more it affects the subsequent output.<br \/>\nTo fix it, you just need to check that the length of the field is not 0:<\/p>\n<p>    del: function() {<br \/>\n        var a = jsKeyboard.currentElement.val();<br \/>\n        if ( a.length &gt; 0 ) {<br \/>\n            var pos = jsKeyboard.currentElementCursorPosition;<br \/>\n            var output = [a.slice(0, pos &#8211; 1), a.slice(pos)].join(&#8221;);<br \/>\n            jsKeyboard.currentElement.val(output);<br \/>\n            jsKeyboard.currentElementCursorPosition&#8211;; \/\/-1 cursor<br \/>\n            jsKeyboard.updateCursor();<br \/>\n        }<br \/>\n    },<\/p>\n<p>https:\/\/wordpress.org\/plugins\/on-screen-keyboard\/<\/p>\n","protected":false},"template":"","class_list":["post-7278731","topic","type-topic","status-publish","hentry","topic-tag-delete"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/7278731","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic"}],"about":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/types\/topic"}],"version-history":[{"count":0,"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/7278731\/revisions"}],"wp:attachment":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/media?parent=7278731"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}