How to capture the “virtual keyboard show/hide” event in Android?

2020 Update This is now possible: On Android 11, you can do view.setWindowInsetsAnimationCallback(object : WindowInsetsAnimation.Callback { override fun onEnd(animation: WindowInsetsAnimation) { super.onEnd(animation) val showingKeyboard = view.rootWindowInsets.isVisible(WindowInsets.Type.ime()) // now use the boolean for something } }) You can also listen to the animation of showing/hiding the keyboard and do a corresponding transition. I recommend reading Android … Read more

Capture console exit C#

I am not sure where I found the code on the web, but I found it now in one of my old projects. This will allow you to do cleanup code in your console, e.g. when it is abruptly closed or due to a shutdown… [DllImport(“Kernel32”)] private static extern bool SetConsoleCtrlHandler(EventHandler handler, bool add); private … Read more

How to set file input value when dropping file on page? [duplicate]

Disclaimer: Correct as of December 2017 and for modern browsers only. TL;DR: Yes, now you can! *if you have a dataTransfer or FileList object Previously, programmatically changing the files input[type=file] field was disabled due to legacy security vulnerabilities, which are fixed on modern browsers. The last of the major browsers (Firefox), has recently enabled us … Read more

JavaScript: remove event listener

You could use a named function expression (in this case the function is named abc), like so: let click = 0; canvas.addEventListener(‘click’, function abc(event) { click++; if (click >= 50) { // remove event listener function `abc` canvas.removeEventListener(‘click’, abc); } // More code here … } Quick and dirty working example: http://jsfiddle.net/8qvdmLz5/2/. More information about … Read more