The keypress event is not triggered when user do backspace or delete on keyboard. This is true according to [webkit-dev] Changes to keyboard event handling
If you want to detect backspace or delete key depress, use keyup or keydown event. keypress event name is misleading, it is actually meaning character inserted (textenter?)
keydown: Fires when the user depresses a key. It repeats while the user keeps the key depressed.
keypress: Fires when an actual character is being inserted in, for instance, a text input. It repeats while the user keeps the key depressed.
keyup: Fires when the user releases a key, after the default action of that key has been performed.
According to above definition, when the user presses special keys such as the arrow keys, backspace, or delete key, the browser should NOT fire keypress events. For cross browser behaviors, check out
http://www.quirksmode.org/dom/events/keys.html
Here is my backspace and delete key depress detection code:
if (e.keyCode === 46 || e.keyCode === 8) {
//do something
return false;
}
Monday, March 18, 2013
Wednesday, March 13, 2013
Back to Windows
It has been around 1 year to use windows, and I sort of forget the short-cut keys on desktop. In current project, there is a requirement to support IE9 web browser on windows, so I have to get Windows back. When community is moving from OS war to browser war, OS platform is not so important for me. For daily use, I really don't care too much about OS now, I just need an IDE, some browser, and command lines. Occasionally I need some tools, fortunately new products or tools usually provide both Windows and Mac support.
Here is the way back to Windows:
Here is the way back to Windows:
- Download and install VMware-Fusion Free Trial from VMWare
- Download and install Windows 7 Professional
- If you have Windows disk, you might also need USB SuperDrive
- Upgrade Windows 7 built-in IE8 to IE9
- Download and Install Adobe Flash (By default, Adobe installed Chrome toolbar and Chrome browser)
- Windows come back again (Windows 7 x64.vmwarevm, which takes around 11GB disk size)
Friday, March 8, 2013
GMail changes height to min-height
In email template we usually use table to control layout, so old school taught us to use tr for row, td for cell etc. My previous blog html email tips has more info about HTML email template tips and tricks. Here I only want to talk about how to deal with Gmail specific behavior.
If we want to control td height, we use inline CSS height to control the height. It works well on most email client, but not Gmail because it changes height to min-height. Two solutions based on my understanding.
1. Put a div to td, and set div height
2. Use line-height which is well supported by email clients
If we want to control td height, we use inline CSS height to control the height. It works well on most email client, but not Gmail because it changes height to min-height. Two solutions based on my understanding.
1. Put a div to td, and set div height
2. Use line-height which is well supported by email clients
Subscribe to:
Posts (Atom)