backspace

JavaScript concat string with backspace

社会主义新天地 提交于 2019-11-30 08:25:39
问题 I have a function f similar to function f(str){ alert("abc"+str); } Now, I want to use JavaScript special charecter "\b" in such a way that I can choose if I want to display the hardcoded string "abc" or not. For example, f("\b\b"+"yz"); //should output "ayz" I tried the same, but it does not work. In other words, I want to concat a string with a backspace character so that I can remove last characters from the string. Can we do this in JavaScript? EDIT The real code is too much big (its a

Backspace doesn't delete inner html tags of a contenteditable DIV in Firefox

こ雲淡風輕ζ 提交于 2019-11-30 05:25:59
问题 I have created a DIV with attribute contenteditable=true and appended children like "span" and "a" with attributes contenteditable=false. Wanted to test if the entire node be deleted with a single backspace and to my surprise Firefox couldnt delete the elements. Also this works as expected in all major desktop browsers except Firefox. Any clues on this or what could be the possible workaround? Found the exact issue on bugzilla here. 回答1: Okay! found the solution... its rather simple than what

Java KeyListener: KeyTyped Backspace, Esc as input

半世苍凉 提交于 2019-11-30 05:18:56
Inside the KeyTyped method, how do I tell if Backspace or Esc is being pressed? BMFredrick Assuming you have attached the KeyListener properly and have implemented the methods required for that KeyListener, to detect specific key-presses simply add the following code: public void keyReleased(KeyEvent ke) { if(ke.getKeyCode() == KeyEvent.VK_BACK_SPACE) { //code to execute if backspace is pressed } if(ke.getKeyCode() == KeyEvent.VK_ESCAPE) { //code to execute if escape is pressed } } The KeyEvent class javadocs can be found at the following link: KeyEvent javadocs . There you can find a list of

Bash read backspace button behavior problem

被刻印的时光 ゝ 提交于 2019-11-30 04:14:14
问题 When using read in bash, pressing backspace does not delete the last character entered, but appears to append a backspace to the input buffer. Is there any way I can change it so that delete removes the last key typed from the input? If so how? Here's a short example prog I'm using it with if it's of any help: #!/bin/bash colour(){ #$1=text to colourise $2=colour id printf "%s%s%s" $(tput setaf $2) "$1" $(tput sgr0) } game_over() { #$1=message $2=score printf "\n%s\n%s\n" "$(colour "Game Over

jquery select dropdown ignores keydown event when it's opened?

霸气de小男生 提交于 2019-11-29 14:04:01
I'm trying to prevent backspace button to go one page back in every browser. For now I'm using this code: $(document).on("keydown", function (e) { if (e.which === 8 && !$(e.target).is("input, textarea")) { e.preventDefault(); } }); It works fine for everything except when a select field dropdown list is opened , this event is ignored and a backspace takes me one page back anyway. How can I solve this problem? Thank you for your answers. Just for the info, this is Google Chrome specific since your code works fine in IE and FF. If you really need this to work you could render a fake dropdown and

'\\b' doesn't print backspace in PyCharm console

孤街浪徒 提交于 2019-11-29 13:56:41
I am trying to update the last line in PyCharm's console. Say, I print a and then I want to change it to c . However, I encounter the following problem. When I run: print 'a\bc' it prints a c while the desired output (which is also what I see in the Windows console) is: c Is there a way to move the cursor back in PyCharm's console? or maybe delete the whole line? It's a known bug: http://youtrack.jetbrains.com/issue/PY-11300 If you care about this, please get an account on the bug tracker and upload the bug to give it more attention. This is not a bug, this is a limitation of the interactive

How to remove first whitespace of a string

一笑奈何 提交于 2019-11-29 12:15:49
I am building a new version of a telephone configuration manager where I am sucking on a stupid problem. You see these telephone .cfg configurations are rely static. So in the old version I made it gave the configuration without a problem. It looks like this: ## Configuration header configuration_1="parram" configuration_2="parram" configuration_3="parram" etc. Now in the new version the configuration is given as this: whitespace ## Configuration header configuration_1="parram" configuration_2="parram" configuration_3="parram" Note that white space is actually white space and that the phone

Disable backspace in textbox via javascript

﹥>﹥吖頭↗ 提交于 2019-11-29 08:03:38
问题 I have a textbox which is extended by an Ajax Control Toolkit calendar. I want to make it so that the user cannot edit the textbox and will have to instead use the calendar extender for input. I have managed to block all keys except backspace! This is what I have so far: <asp:TextBox ID="TextBox1" runat="server" onKeyPress="javascript: return false;" onKeyDown="javascript: return false;" onPaste="javascript: return false;" /> How would I also disable backspace within the textbox using

JavaScript concat string with backspace

一个人想着一个人 提交于 2019-11-29 06:36:31
I have a function f similar to function f(str){ alert("abc"+str); } Now, I want to use JavaScript special charecter "\b" in such a way that I can choose if I want to display the hardcoded string "abc" or not. For example, f("\b\b"+"yz"); //should output "ayz" I tried the same, but it does not work. In other words, I want to concat a string with a backspace character so that I can remove last characters from the string. Can we do this in JavaScript? EDIT The real code is too much big (its a HUGE 1 liner that concats many many strings). To map that in above example, we cannot edit the function f

Java KeyListener: KeyTyped Backspace, Esc as input

荒凉一梦 提交于 2019-11-29 02:55:05
问题 Inside the KeyTyped method, how do I tell if Backspace or Esc is being pressed? 回答1: Assuming you have attached the KeyListener properly and have implemented the methods required for that KeyListener, to detect specific key-presses simply add the following code: public void keyReleased(KeyEvent ke) { if(ke.getKeyCode() == KeyEvent.VK_BACK_SPACE) { //code to execute if backspace is pressed } if(ke.getKeyCode() == KeyEvent.VK_ESCAPE) { //code to execute if escape is pressed } } The KeyEvent